timed string functions
Displaying 1-20 of 23 total.
12 next
Please enter a numerical value for the importance of this sticky.
Enter 0 to unsticky.
gannon

I did some tests on the string functions using the timere and here is what I found.

The len of longstring and longstring2 is 10000
The time to go though a simple empty for loop 20000 times is 1
The time to mid(longstring,0,1); 20000 times is 232
The time to dumString = mid(longstring,500000,1); 20000 times is 258
The time to dumString = mid(longstring,0,500000); 20000 times is 538
The time to dumString = right(longstring,500000); 20000 times is 536
The time to dumString = right(longstring,1); 20000 times is 232
The time to dumString = left(longstring,500000); 20000 times is 550
The time to dumString = left(longstring,1); 20000 times is 235
The time to dummy = strcmp(longstring,longstring2); 20000 times is 362
The time to dummy = strcmp(longstring,longstringcopy); 20000 times is 428
The time to dummy = len(longstring); 20000 times is 172
The time to do dumString = longstring; 20000 times is 218
The time to do dummy = 23; 20000 times is 0

comments
some things jumped out at me
with mid it didn't matter where you started
comparing equal strings takes longer than unequal strings
assinment of strings is slow

any comments, any other functions you want tested (I think this kind of stuff is fun)

Posted on 2004-06-11 02:25:09 (last edited on 2004-06-11 02:26:15)

Omni

How long does it take to draw one line?
How long does it take to blit a one line image?
How much slower is Rotscale than normal Blitting?

Posted on 2004-06-11 02:57:50

mcgrue

Quote:Originally posted by gannon


comparing equal strings takes longer than unequal strings


Of course. You have to check every single element of equal strings to verify their equality, while as soon as you hit a different character in unequal strings, you have your answer.

Posted on 2004-06-11 03:25:06

gannon

Quote:Originally posted by mcgrue

Quote:Originally posted by gannon


comparing equal strings takes longer than unequal strings


Of course. You have to check every single element of equal strings to verify their equality, while as soon as you hit a different character in unequal strings, you have your answer.



in my case it was different right away so if it just did that it would be much faster

(I thought it also could be used to order them am I wrong on that?)

Posted on 2004-06-11 03:37:06

gannon

dummyimage is a blank image created with new image with the dimentions 800x600
dummyimage2 is a colored image created with new image with the dimentions 100x200 and rectfill
The time to Line(0, 0, 1, 0, gray , dummyimage); 2000 times is 0
The time to Line(0, 0, 800, 0, gray , dummyimage); 2000 times is 12
The time to Line(0, 0, 692, 400, gray , dummyimage); 2000 times is 15
The time to Blit(0, 0, dummyimage2 , dummyimage); 2000 times is 15
The time to Blit(0, 500, dummyimage2 , dummyimage); 2000 times is 6
The time to RotScale(0, 0,90,1, dummyimage2 , dummyimage); 2000 times is 1053
The time to RotScale(0, 500,90,1, dummyimage2 , dummyimage); 2000 times is 1044
The time to RotScale(0, 0,180,1, dummyimage2 , dummyimage); 2000 times is 1045
The time to RotScale(0, 0,90,2, dummyimage2 , dummyimage); 2000 times is 1051

wow now that is what you call a difference

Posted on 2004-06-11 03:54:42

mcgrue

Do a test of writing your own recoloring function! :D

Search every pixel in a 100x100 image for a certain color, and change it to another color!

(make sure the function works before timing it.)

Also, test the time of log statements.

Posted on 2004-06-11 04:04:43

el_desconocido

Quote:Originally posted by gannon

(I thought it also could be used to order them am I wrong on that?)

I can confirm that at least when comparing single characters, -1 is returned if the character in the string charA comes before the one in string charB, and 1 is returned if it comes after in the example:
sort = strcmp(charA, charB);

I would guess longer strings would yeild the same result.
El

Posted on 2004-06-11 04:07:29

Omni

Rotscale is exponentially slower. Darn trig math.

Posted on 2004-06-11 04:08:21

gannon

The time to CallFunction('dummyFunction'); 2000 times is 10
The time to log('this is the song that never ends'); 2000 times is 110

question how do you put " into strings in verge?
I will work on the color replacement in a min.

Posted on 2004-06-11 04:15:50

Omni

answer: you cannot. In order to fake it, you may wish to change the font glyph of another unused character (such as ^) to the quotation, and use it instead.

Edit: This is incorrect. The following post has the correct answer. -Grue

Posted on 2004-06-11 04:20:46 (last edited on 2004-06-11 06:19:53)

el_desconocido

Assuming you don't wish to use font subsets deluxe and type %q in your string, use:
"A " + chr(34) + "shameless" + chr(34) + " plug!"
to print:
A "shameless" plug!

El

[misplaced spaces]

Posted on 2004-06-11 04:22:13 (last edited on 2004-06-11 04:28:12)

gannon

colorImage is a 100 x 100 image colored RGB(255,0,0) by fill rect
The time to changeColor(RGB(255,50,0),gray,colorImage); 2000 times is 1602
The time to changeColor(RGB(255,0,0),gray,colorImage); 2000 times is 1568

here is the code

edit see next post

Posted on 2004-06-11 04:54:26 (last edited on 2004-06-11 05:45:05)

gannon

the less than things messed me up


void changeColor(int from, int to, int image){

int height = ImageHeight(image);
int width = ImageWidth(image);

int h = 0;
int w = 0;

for(h = 0; h < height; h++){
for(w = 0; w < width; w++){
if(GetPixel(w, h, image) == from){
SetPixel(w, h, to, image);
}
}
}
}


edit: wow the tabs are big here I have mine set at 4
edit of the edit: don't edit something you had to put the < in

Posted on 2004-06-11 05:00:11 (last edited on 2004-06-11 05:09:59)

RageCage

whats your computer's specs?

Posted on 2004-06-11 06:04:54

gannon

1.6 Ghz pentium 4
384 MB of ram
Geforce 3 video card

but this is not about how fast something will run it is about what is faster than a different thing (also remember look how many times each one ran)

Posted on 2004-06-11 06:16:34

vecna

Some of these timings are of questionable usefulness.

The time to execute a CallFunction for instance will vary a lot depending on how many functions there are, and how soon in the function list it will find the match. I've been meaning to generate a binary tree for the function list so that search will go much faster, but I have a lot of higher priority things to get to first.

There's others, but the point is, just remember that these things will vary. The speed of any blitter function will depend a lot on the size of the source and dest images.

Log is slow because the file is open, written to, flushed and closed each time its called, rather than keeping the logfile open and just writing to it as you go, because if there's an abnormal termination, the logfile wouldn't be very useful otherwise.

Posted on 2004-06-11 18:55:12

gannon

thats why I said I wasn't testing how fast the things were. this is just to get some idea of the speed of things. (unless you give us the real speeds) It would be usefull to get a general feel on the speed of various things.

Posted on 2004-06-11 20:03:06

blues_zodiakos

With RotScale, the speed depends GREATLY on the size of the source image. With a RotScaled sprite of 8x8, I noticed there was not an extreme difference in speed compared to TBlitting. However, as the sprite got larger (the source image, that is), there was, as someone said, an exponential speed decrease. Does using power of 2 source images make any difference in speed as far as RotScale is concerned?

Posted on 2004-06-17 13:03:12

vecna

Nope.

Posted on 2004-06-17 13:11:58

aen

The great thing though, is that instead of rendering a bunch of rotated images yourself in a paint program you can just render all the images programmatically in V3 at varying angles and then use those.

It'd be nifty if someone made a simple little library to do automatic caching of various image handles at different angles and sizes. All tidily inside a CachedRotScale() or something.

Depending on the size, number, and angles used it could eat up a hell of a lot of memory in a flash, but unless you're doing some ultra pimped out Asteroids clone it wouldn't be anything to worry about!

Posted on 2004-06-18 00:54:46


Displaying 1-20 of 23 total.
12 next
 
Newest messages

Ben McGraw's lovingly crafted this website from scratch for years.
It's a lot prettier this go around because of Jon Wofford.
Verge-rpg.com is a member of the lunarnet irc network, and would like to take this opportunity to remind you that regardless how babies taste, it is wrong to eat them.