Skip to content

Instantly share code, notes, and snippets.

@thinca
Created June 5, 2009 04:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thinca/124047 to your computer and use it in GitHub Desktop.
Save thinca/124047 to your computer and use it in GitHub Desktop.
let list = []
echo 'call add(list, i)'
let time = reltime()
for i in range(10000)
call add(list, i)
endfor
echo reltimestr(reltime(time))
let list = []
echo 'let list += [i]'
let time = reltime()
for i in range(10000)
let list += [i]
endfor
echo reltimestr(reltime(time))
let list = []
echo 'let list = list + [i]'
let time = reltime()
for i in range(10000)
let list = list + [i]
endfor
echo reltimestr(reltime(time))
let list = []
echo 'call insert(list, i)'
let time = reltime()
for i in range(10000)
call insert(list, i)
endfor
echo reltimestr(reltime(time))
let list = []
echo 'let list = [i] + list'
let time = reltime()
for i in range(10000)
let list = [i] + list
endfor
echo reltimestr(reltime(time))
finish
=> result (Intel Core2 2.40GHz + 2.00GB RAM)
call add(list, i)
0.066588
let list += [i]
0.070910
let list = list + [i]
14.713714
call insert(list, i)
0.069628
let list = [i] + list
15.083124
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment