The MASM Forum Archive 2004 to 2012

General Forums => The Laboratory => Topic started by: brethren on November 26, 2010, 08:20:07 PM

Title: Signed dword to ascii benchmark
Post by: brethren on November 26, 2010, 08:20:07 PM
i've just updated my dwtoa routine with the optimizations that hutch made here
http://www.masm32.com/board/index.php?topic=15427.msg126329#msg126329

the zip includes a benchmark against the current masm32 dwtoa. use console, assemble and link to build :wink

106 cycles for dwtoa-masmlib
73 cycles for dwtoa2-brethren
--test finished--


Title: Re: Signed dword to ascii benchmark
Post by: hutch-- on November 26, 2010, 08:34:20 PM
Looks good, we must try it is a benchmark that sweeps it over more of the signed range so we know how it performs on short to long numbers.


104 cycles for dwtoa-masmlib
72 cycles for dwtoa2-brethren
--test finished--
Title: Re: Signed dword to ascii benchmark
Post by: oex on November 26, 2010, 09:08:36 PM
107 cycles for dwtoa-masmlib
73 cycles for dwtoa2-brethren
--test finished--
Title: Re: Signed dword to ascii benchmark
Post by: lingo on November 26, 2010, 09:47:30 PM
 :wink
98 cycles for dwtoa-masmlib
73 cycles for dwtoa2-brethren
68 cycles for dwtoa3-Lingo
21 cycles for sdwtoa_ex-Lingo
--test finished--

Title: Re: Signed dword to ascii benchmark
Post by: brethren on November 26, 2010, 10:28:30 PM
107 cycles for dwtoa-masmlib
72 cycles for dwtoa2-brethren
76 cycles for dwtoa3-Lingo
24 cycles for sdwtoa_ex-Lingo
--test finished--


24 cycles :eek i'll have to run that through olly and see how its done

QuoteLooks good, we must try it is a benchmark that sweeps it over more of the signed range so we know how it performs on short to long numbers.

i pick 80000000h as this number takes the longest path through the code though i think a ranged test would be best just to make sure. what do you think would be the fairest way to test these algos?
Title: Re: Signed dword to ascii benchmark
Post by: hutch-- on November 26, 2010, 11:51:57 PM
Two things, ensure you get correct results across the entire signed range then test the algo on a selection of different number lengths. The number length effects the speed for the obvious reason that it takes longer to write a longer string result so if you range from 10 chars down to 1 and sweep them you get the best averaging. Also note that you would bias the code to suit larger numbers as there are more of them.
Title: Re: Signed dword to ascii benchmark
Post by: brethren on November 27, 2010, 01:07:40 PM
the algos has been tested over the full signed range and is correct :wink

so for a benchmark i could fill an array with -1, -12, -123, -1234 etc etc 1, 12 ,123, 1234 etc etc and loop through converting each number in turn and then do the same with the algo from masm32 and divide the cycles by the number of array elements to get the average.

or i could test each number individually, maybe that'd be best for showing up any irregularities

i'll get on this today :U
Title: Re: Signed dword to ascii benchmark
Post by: hutch-- on November 27, 2010, 01:19:02 PM
Basically yes, the algos are length dependent so if you test from 1 to 10 characters in both positive and negative numbers you will know reasonably well how fast it is. As far as the loop count, just try for about a half a second or so to get the variance down low enough.
Title: Re: Signed dword to ascii benchmark
Post by: brethren on November 27, 2010, 02:33:06 PM
hutch, i decided to test each number individually as it would give the most accurate results. you'll find two asm files, one tests positive numbers and the other tests negative numbers. use console, assemble and link to build :wink

AMD Turion(tm) 64 X2 Mobile Technology TL-52
Timing positive conversions
---------------------------
9
----------
25 cycles for dwtoa-masmlib
12 cycles for dwtoa2-brethren

99
----------
26 cycles for dwtoa-masmlib
19 cycles for dwtoa2-brethren

999
----------
36 cycles for dwtoa-masmlib
28 cycles for dwtoa2-brethren

9999
----------
42 cycles for dwtoa-masmlib
35 cycles for dwtoa2-brethren

99999
----------
50 cycles for dwtoa-masmlib
36 cycles for dwtoa2-brethren

999999
----------
58 cycles for dwtoa-masmlib
44 cycles for dwtoa2-brethren

9999999
----------
65 cycles for dwtoa-masmlib
52 cycles for dwtoa2-brethren

99999999
----------
72 cycles for dwtoa-masmlib
59 cycles for dwtoa2-brethren

999999999
----------
98 cycles for dwtoa-masmlib
66 cycles for dwtoa2-brethren

1000000000
----------
104 cycles for dwtoa-masmlib
72 cycles for dwtoa2-brethren

--test finished--


Timing negative conversions
---------------------------
-9
----------
24 cycles for dwtoa-masmlib
13 cycles for dwtoa2-brethren

-99
----------
29 cycles for dwtoa-masmlib
21 cycles for dwtoa2-brethren

-999
----------
39 cycles for dwtoa-masmlib
29 cycles for dwtoa2-brethren

-9999
----------
45 cycles for dwtoa-masmlib
36 cycles for dwtoa2-brethren

-99999
----------
55 cycles for dwtoa-masmlib
38 cycles for dwtoa2-brethren

-999999
----------
61 cycles for dwtoa-masmlib
45 cycles for dwtoa2-brethren

-9999999
----------
68 cycles for dwtoa-masmlib
55 cycles for dwtoa2-brethren

-99999999
----------
73 cycles for dwtoa-masmlib
61 cycles for dwtoa2-brethren

-999999999
----------
100 cycles for dwtoa-masmlib
68 cycles for dwtoa2-brethren

-1000000000
----------
107 cycles for dwtoa-masmlib
73 cycles for dwtoa2-brethren

--test finished--


btw this test has thrown up an unusual result with dwtoa masmlib. between 8 and 9 character length conversions there is a disproportionate increase in the cycles used
Title: Re: Signed dword to ascii benchmark
Post by: frktons on November 27, 2010, 05:50:17 PM
With so many Testbeds around you are still working with this sort of...


Timing positive conversions
---------------------------
9
----------
18 cycles for dwtoa-masmlib
10 cycles for dwtoa2-brethren

99
----------
25 cycles for dwtoa-masmlib
16 cycles for dwtoa2-brethren

999
----------
36 cycles for dwtoa-masmlib
20 cycles for dwtoa2-brethren

9999
----------
44 cycles for dwtoa-masmlib
28 cycles for dwtoa2-brethren

99999
----------
55 cycles for dwtoa-masmlib
34 cycles for dwtoa2-brethren

999999
----------
61 cycles for dwtoa-masmlib
39 cycles for dwtoa2-brethren

9999999
----------
72 cycles for dwtoa-masmlib
48 cycles for dwtoa2-brethren

99999999
----------
77 cycles for dwtoa-masmlib
54 cycles for dwtoa2-brethren

999999999
----------
88 cycles for dwtoa-masmlib
63 cycles for dwtoa2-brethren

1000000000
----------
95 cycles for dwtoa-masmlib
68 cycles for dwtoa2-brethren

--test finished--

:lol
Title: Re: Signed dword to ascii benchmark
Post by: clive on November 27, 2010, 09:31:07 PM
Atom N450 1.66 GHz
Timing positive conversions
---------------------------
9
----------
64 cycles for dwtoa-masmlib
38 cycles for dwtoa2-brethren

99
----------
87 cycles for dwtoa-masmlib
60 cycles for dwtoa2-brethren

999
----------
130 cycles for dwtoa-masmlib
105 cycles for dwtoa2-brethren

9999
----------
160 cycles for dwtoa-masmlib
134 cycles for dwtoa2-brethren

99999
----------
196 cycles for dwtoa-masmlib
138 cycles for dwtoa2-brethren

999999
----------
205 cycles for dwtoa-masmlib
119 cycles for dwtoa2-brethren

9999999
----------
201 cycles for dwtoa-masmlib
136 cycles for dwtoa2-brethren

99999999
----------
218 cycles for dwtoa-masmlib
157 cycles for dwtoa2-brethren

999999999
----------
243 cycles for dwtoa-masmlib
172 cycles for dwtoa2-brethren

1000000000
----------
282 cycles for dwtoa-masmlib
184 cycles for dwtoa2-brethren

--test finished--
Timing negative conversions
---------------------------
-9
----------
67 cycles for dwtoa-masmlib
39 cycles for dwtoa2-brethren

-99
----------
81 cycles for dwtoa-masmlib
67 cycles for dwtoa2-brethren

-999
----------
139 cycles for dwtoa-masmlib
111 cycles for dwtoa2-brethren

-9999
----------
164 cycles for dwtoa-masmlib
136 cycles for dwtoa2-brethren

-99999
----------
200 cycles for dwtoa-masmlib
141 cycles for dwtoa2-brethren

-999999
----------
182 cycles for dwtoa-masmlib
119 cycles for dwtoa2-brethren

-9999999
----------
198 cycles for dwtoa-masmlib
137 cycles for dwtoa2-brethren

-99999999
----------
224 cycles for dwtoa-masmlib
156 cycles for dwtoa2-brethren

-999999999
----------
259 cycles for dwtoa-masmlib
179 cycles for dwtoa2-brethren

-1000000000
----------
262 cycles for dwtoa-masmlib
183 cycles for dwtoa2-brethren

--test finished--
Title: Re: Signed dword to ascii benchmark
Post by: hutch-- on November 28, 2010, 11:49:26 AM
Test machine is a 3 gig Core2 Quad.

Positive.


Timing positive conversions
---------------------------
9
----------
17 cycles for dwtoa-masmlib
10 cycles for dwtoa2-brethren

99
----------
25 cycles for dwtoa-masmlib
17 cycles for dwtoa2-brethren

999
----------
35 cycles for dwtoa-masmlib
21 cycles for dwtoa2-brethren

9999
----------
43 cycles for dwtoa-masmlib
29 cycles for dwtoa2-brethren

99999
----------
51 cycles for dwtoa-masmlib
32 cycles for dwtoa2-brethren

999999
----------
61 cycles for dwtoa-masmlib
40 cycles for dwtoa2-brethren

9999999
----------
72 cycles for dwtoa-masmlib
47 cycles for dwtoa2-brethren

99999999
----------
81 cycles for dwtoa-masmlib
57 cycles for dwtoa2-brethren

999999999
----------
87 cycles for dwtoa-masmlib
64 cycles for dwtoa2-brethren

1000000000
----------
94 cycles for dwtoa-masmlib
71 cycles for dwtoa2-brethren

--test finished--


Negative.



Timing negative conversions
---------------------------
-9
----------
21 cycles for dwtoa-masmlib
10 cycles for dwtoa2-brethren

-99
----------
25 cycles for dwtoa-masmlib
18 cycles for dwtoa2-brethren

-999
----------
36 cycles for dwtoa-masmlib
23 cycles for dwtoa2-brethren

-9999
----------
46 cycles for dwtoa-masmlib
30 cycles for dwtoa2-brethren

-99999
----------
51 cycles for dwtoa-masmlib
34 cycles for dwtoa2-brethren

-999999
----------
62 cycles for dwtoa-masmlib
41 cycles for dwtoa2-brethren

-9999999
----------
83 cycles for dwtoa-masmlib
49 cycles for dwtoa2-brethren

-99999999
----------
84 cycles for dwtoa-masmlib
57 cycles for dwtoa2-brethren

-999999999
----------
104 cycles for dwtoa-masmlib
83 cycles for dwtoa2-brethren

-1000000000
----------
97 cycles for dwtoa-masmlib
72 cycles for dwtoa2-brethren

--test finished--
Title: Re: Signed dword to ascii benchmark
Post by: brethren on November 29, 2010, 03:12:38 PM
thanks to everyone who posted test results :wink i think thats about as fast as we can make it so its time for me to move onto optimizing other procedures