fix: replace string length calls with counter in map_string benchmarks across all languages

This commit is contained in:
Bob Nystrom
2015-09-12 16:59:30 +00:00
parent e0fda5e315
commit 9b002c6d67
5 changed files with 13 additions and 8 deletions
+3 -2
View File
@@ -80,9 +80,10 @@ end
local start = os.clock()
local map = {}
local i = 0
for _, key in ipairs(keys) do
map[key] = string.len(key)
map[key] = i
i = i + 1
end
local sum = 0
+3 -2
View File
@@ -81,9 +81,10 @@ for animal in animals:
start = time.clock()
map = {}
i = 0
for key in keys:
map[key] = len(key)
map[key] = i
i += 1
sum = 0
for key in keys:
+3 -2
View File
@@ -80,9 +80,10 @@ end
start = Time.now
map = Hash.new
i = 0
for key in keys
map[key] = key.length
map[key] = i
i += 1
end
sum = 0
+3 -1
View File
@@ -81,8 +81,10 @@ var start = IO.clock
var map = {}
var i = 0
for (key in keys) {
map[key] = key.count
map[key] = i
i = i + 1
}
var sum = 0