$ src/luajit test1.lua
test3/lua 0.000812
test2/lua 0.047739
$ src/luajit test2.lua
test2/lua 0.050938
test3/lua 0.000856
This file contains hidden or 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
--- Raw source --- | |
() { | |
var sum = 0; | |
for (var i = 0; i < 1000; i++) { | |
sum += i; | |
} | |
} | |
--- Optimized code --- |
This file contains hidden or 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
-- Make this function more LuaJIT friendly while keeping its semantics intact. | |
-- Assume that t are always small table literals (<5 elements) and surrounding loop | |
-- is traced. | |
local function len(t) | |
return #t | |
end | |
-- Make this loop 50x faster by tweaking len above. | |
local sum = 0 | |
for i = 1, 10000000 do |
$ time ./pypy-c test.py 1000000
./pypy-c test.py 1000000 11.65s user 0.41s system 99% cpu 12.063 total
$ time src/luajit test.lua 1000000
src/luajit test.lua 1000000 2.43s user 0.01s system 100% cpu 2.438 total
$ time dart test.dart 1000000
dart test.dart 1000000 0.29s user 0.02s system 107% cpu 0.284 total
This file contains hidden or 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
;; B2 | |
;; Loop 0 | |
;; CheckStackOverflow:24(depth 1) | |
0x7f845e4afcb6 48c7c25884f501 movq rdx,0x1f58458 | |
0x7f845e4afcbd 483b22 cmpq rsp,[rdx] | |
0x7f845e4afcc0 0f862c000000 jna 0x7f845e4afcf2 | |
;; Branch if RelationalOp:26(<, v6, v8) T{bool} goto (12, 4) | |
0x7f845e4afcc6 4881f9204e0000 cmpq rcx,0x4e20 | |
0x7f845e4afccd 0f8d15000000 jge 0x7f845e4afce8 | |
;; B12 |
This file contains hidden or 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
local level = 2 | |
while true do | |
local info = debug.getinfo (level) | |
if not info then break end | |
p(string.format("-- #%d | [%s] function %s at %s:%d (defined at %d)", level, tostring(info.func), info.name or "?", info.source or "", info.currentline or -1, info.linedefined or -1)) | |
local localIdx = 1 | |
while true do | |
local name, value = debug.getlocal(level, localIdx) |
This file contains hidden or 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
After Optimizations | |
==== file:///usr/local/google/home/vegorov/Downloads/benchmark_mirrors.dart_::_testWithoutMirrors | |
0: B0[graph]:2 { | |
v0 <- Constant(#null) T{Null?} | |
v1 <- Constant(#<optimized out>) | |
v2 <- Constant(#Context@0x7f6422ac3461 num_variables: 0) T{Context} | |
v3 <- Parameter(0) | |
v4 <- Constant(#TypeArguments: [Type: class 'int']) T{TypeArguments} | |
v5 <- Constant(#1) [1, 1] T{_Smi} | |
v12 <- Constant(#true) T{bool} |
This file contains hidden or 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
#define LIST(V) \ | |
V(A) \ | |
V(B) \ | |
V(C) | |
enum ListOfMyFavoriteEnglishLetters { | |
#define F(name) k##name, | |
LIST(F) | |
#undef F |
This file contains hidden or 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
// ../jsshell-35.0/js y0.js | |
// TryCatch x 2,139,927 ops/sec ±0.96% (65 runs sampled) | |
// FastTry x 2,079,778 ops/sec ±1.07% (63 runs sampled) | |
// Fastest is TryCatch | |
load("lodash.js"); | |
load("benchmark.js"); | |
function fastTry (fn) { |
This file has been truncated, but you can view the full file.
This file contains hidden or 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
--- FUNCTION SOURCE () id{0,0} --- | |
var iterations = 2; | |
print("Running (" + iterations + ")... "); | |
var testData = new Uint8Array(1024 * 1024); | |
for (var i = 0; i < 1024 * 1024; i++) { | |
testData[i] = i % 256; | |
} | |
var key = [0x80]; for (i = 1; i < 32; i++) key[i] = 0x07; | |
var nonce = []; for (i = 0; i < 8; i++) nonce[i] = 0x01; | |
if (iterations < 100) { |