-
-
Save Zig1375/a972207158edb523ce04219d84885469 to your computer and use it in GitHub Desktop.
Benchmark for NodeJS and Ruby
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
class MyClass { | |
constructor(aa, bb) { | |
this.a = aa; | |
this.b = bb; | |
} | |
sum() { | |
return this.a + this.b; | |
} | |
} | |
const cnt = 10000000 | |
const list = []; | |
for(let i = 0; i < cnt; i++) { | |
list.push(new MyClass(i, i - 10)); | |
} | |
let res = 0 | |
list.forEach((it) => { | |
res += it.sum(); | |
}); | |
console.log(res) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MyClass | |
def initialize(aa, bb) | |
@a = aa | |
@b = bb | |
end | |
def sum | |
@a + @b | |
end | |
end | |
cnt = 10000000 | |
list = [] | |
cnt.times.each do|i| | |
list << MyClass.new(i, i - 10) | |
end | |
res = 0 | |
list.each do|it| | |
res += it.sum | |
end | |
puts res |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment