🐛 fix global/local debug index

This commit is contained in:
ValKmjolnir
2025-03-12 21:37:29 +08:00
parent a7a2a0a369
commit eeb126ab65
2 changed files with 68 additions and 25 deletions

View File

@@ -9,15 +9,18 @@ var test_func = func(test_processes...) {
var info = runtime.gc.info();
var gc_total = info.total;
var duration = 0;
foreach(var f; test_processes) {
println("[", os.time(), "] testing ", id(f));
foreach (var t; test_processes) {
var name = t[0];
var f = t[1];
print("[", os.time(), "] testing ", name, " : ");
time_stamp.stamp();
f();
duration = time_stamp.elapsedMSec();
info = runtime.gc.info();
println("[", os.time(), "] ", duration, " ms, gc ",
println(duration, " ms, gc ",
(info.total-gc_total)*100/duration, "%, ",
1000/duration, " cps");
1000/duration, " count/sec"
);
gc_total = info.total;
}
@@ -34,23 +37,25 @@ var test_func = func(test_processes...) {
println("---------------------");
}
var MAX_ITER_NUM = 2e5;
var append_vec = func {
var res = [];
for(var i=0; i<1e6; i+=1) {
append(res, [1]);
for(var i=0; i<MAX_ITER_NUM; i+=1) {
append(res, [1, 2, 3, 4]);
}
}
var append_hash = func {
var res = [];
for(var i=0; i<1e6; i+=1) {
append(res, {a:1, b:2});
for(var i=0; i<MAX_ITER_NUM; i+=1) {
append(res, {a:1, b:2, c:3, d:4});
}
}
var append_func = func {
var res = [];
for(var i=0; i<1e6; i+=1) {
for(var i=0; i<MAX_ITER_NUM; i+=1) {
append(res, func {
println(arg);
});
@@ -59,23 +64,40 @@ var append_func = func {
var append_vec_in_vec = func {
var res = [];
for(var i=0; i<1e6; i+=1) {
append(res, [[]]);
for(var i=0; i<MAX_ITER_NUM; i+=1) {
append(res, [[], [], [], []]);
}
}
var append_hash_in_vec = func {
var res = [];
for(var i=0; i<MAX_ITER_NUM; i+=1) {
append(res, {a:{}, b:{}, c:{}, d:{}});
}
}
var append_vec_in_hash = func {
for(var i=0; i<1e6; i+=1) {
append([], {a:[], b:[]});
var res = [];
for(var i=0; i<MAX_ITER_NUM; i+=1) {
append(res, {a:[], b:[], c:[], d:[]});
}
}
for(var i=0; i<10; i+=1) {
var append_hash_in_hash = func {
var res = [];
for(var i=0; i<MAX_ITER_NUM; i+=1) {
append(res, {a:{}, b:{}, c:{}, d:{}});
}
}
for (var i = 0; i < 10; i += 1) {
test_func(
append_vec,
append_hash,
append_func,
append_vec_in_vec,
append_vec_in_hash
["vec", append_vec],
["hash", append_hash],
["func", append_func],
["vec<vec>", append_vec_in_vec],
["vec<hash>", append_hash_in_vec],
["hash<str, vec>", append_vec_in_hash],
["hash<str, hash>", append_hash_in_hash]
);
}