Re: append() versus &=
- Posted by jiri babor <jiri_babor at HOTMAIL.COM> Sep 13, 2000
- 405 views
Lewis, I am probably too dense, but Robert's reply was not of much help, as far as I am concern... I think your benchmark is completely dominated by the troublesome rand() function. Take it out of the loop and you will see Rob indeed optimised the common case: s1 = append(s1, s2) I modified your code slightly, improving the timer resolution and bumping the iterations up too: include machine.e -- tick_rate() constant its = 1000000 constant frmt = "%0.03f" constant chars = 20 sequence s,temp atom t integer rits rits = rand(its) tick_rate(200) printf (1, "Appending benchmarks for Euphoria using %d iterations\n", its) puts (1, "\nAppending integers again...\n") puts (1, "append():\t") s = {} t=time() for i = 1 to its do s = append (s, rits) end for t = time() - t printf (1, frmt & "\n", t) puts (1, "&=:\t\t") s = {} t = time () for i = 1 to its do s &= rits end for t = time() - t printf (1, frmt & "\n", t) printf (1, "\nAppending strings (%d characters)...\n", chars) puts (1, "append():\t") s = {} temp = rand(repeat (255,chars)) t=time() for i = 1 to its do s = append (s, temp) end for t = time() - t printf (1, frmt & "\n", t) puts (1, "&=:\t\t") s = {} t = time () for i = 1 to its do s &= {temp} end for t = time() - t printf (1, frmt & "\n", t) puts (1, "\nAppending complex sequences eg: {a,{a,{a}}}...\n") puts (1, "append():\t") s = {} temp = rand({its,{its,{its}}}) t=time() for i = 1 to its do s = append (s, temp) end for t = time() - t printf (1, frmt & "\n", t) puts (1, "&=:\t\t") s = {} t = time () for i = 1 to its do s &= {temp} end for t = time() - t printf (1, frmt & "\n", t) _________________________________________________________________________ Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com. Share information about yourself, create your own public profile at http://profiles.msn.com.