benchmark dict list and string, D vs python vs lua

lzzll ownrepos at gmail.com
Thu Apr 5 12:00:14 PDT 2012


Hey, I wrote some code to benchmark dict list and string in D, 
python and lua.
D is a great language, but some library look comparatively slow.
Some where may be wrong, I start D just today.

D test:
code: http://pastebin.com/qF7N4wLx
dict set: 2.251s
dict get: 1.957s
dict cleat: 0.00s
list set: 0.085s
list get: 0.007s
list each: 0.014s
str find: 1.254s
str replace: 1.870s

Python test:
code: http://pastebin.com/m3qMjPcM
dict set: 1.05s
dict get: 0.75s
dict cleat: 0.11s
list set: 0.02s
list get: 0.09s
list each: 0.09s
str find: 0.94s
str replace: 0.67s

Lua test:
code: http://pastebin.com/TFTnsWzX
dict set: 2.11s
dict get: 0.87s
dict cleat: 0.19s
list set: 0.33s
list get: 0.03s
list each: 0.09s
str find: 0.94s
str replace: 1.10s

Compare (> mean faster than):
dict set: python > lua > D
dict get: python > lua > D
dict clear: D > lua > python
list set: python > D > lua
list get: D > lua > python
list each: D > lua = python
str find: python = lua > D
str replace: python > lua > D

C algorithm (with -O3):
map tree set: 0.70s
map tree get: 0.39s
map tree clear: 0.23
chain set: 0.09s
chain get: too large ...
chain each: 0.05s
variable length list set: 0.025s
variable length list get: 0.01s
variable length list each: 0.01s
quick search find: 0.29s
remalloc replace: 0.40s
chain replace: 0.40s

I think the one of problems is to!string(int) too slow, snprintf 
will better.


More information about the Digitalmars-d mailing list