add profiling and testing
This commit is contained in:
parent
05acefd683
commit
5690ee7fba
|
@ -785,7 +785,7 @@ Object.defineProperty(String.prototype, 'name', {
|
|||
Object.defineProperty(String.prototype, 'set_name', {
|
||||
value: function(name) {
|
||||
var dir = this.dir();
|
||||
return this.dir() + name + "." + this.ext();
|
||||
return this.dir() + "/" + name + "." + this.ext();
|
||||
}
|
||||
});
|
||||
|
||||
|
|
69
scripts/stdprofile.js
Normal file
69
scripts/stdprofile.js
Normal file
|
@ -0,0 +1,69 @@
|
|||
var aa = [1,2,3,4,5,6,7,8,9,10];
|
||||
|
||||
/*
|
||||
var ta = [1,2,3,4,5,6,7,8,9,10];
|
||||
|
||||
function tadd(a,b)
|
||||
{
|
||||
var c = a.slice();
|
||||
for (var i = 0; i < a.length; i++)
|
||||
c[i] += b[i];
|
||||
return c;
|
||||
}
|
||||
|
||||
say(vector.angle_between([0,1], [1,0]));
|
||||
|
||||
function test_arrays(ta, tb)
|
||||
{
|
||||
profile.cpu(_=> ta.add(tb), 100000, "add two arrays");
|
||||
say(ta.add(tb));
|
||||
}
|
||||
*/
|
||||
//for (var i = 2; i <= 10; i++) {
|
||||
// say(`TESTING FOR ${i} ARRAY`);
|
||||
// test_arrays(ta.slice(0,i), ta.slice(0,i));
|
||||
//}
|
||||
/*
|
||||
say(prosperon.guid());
|
||||
say(prosperon.guid());
|
||||
var aa = [];
|
||||
var ao = {};
|
||||
|
||||
var amt = 10000;
|
||||
|
||||
profile.cpu(_ => prosperon.guid(), 10000, "guid generation");
|
||||
|
||||
profile.cpu(_ => aa.push(1), amt, "add one to array");
|
||||
profile.cpu(_ => ao[prosperon.guid()] = 1, amt, "add one via guid");
|
||||
|
||||
var aos = Object.keys(ao);
|
||||
|
||||
say(aa.length);
|
||||
|
||||
var useguid = aos[amt/2];
|
||||
|
||||
say(useguid);
|
||||
|
||||
var tries = [];
|
||||
for (var i = 0; i < amt; i++)
|
||||
tries[i] = aa.slice();
|
||||
|
||||
var rmamt = amt/2;
|
||||
profile.cpu(x => tries[x].remove(rmamt), amt, "remove from array");
|
||||
|
||||
for (var i = 0; i < amt; i++) {
|
||||
tries[i] = {};
|
||||
for (var j in ao) tries[i][j] = ao[j];
|
||||
}
|
||||
|
||||
|
||||
profile.cpu(x => delete tries[x][useguid], amt, "delete with guid");
|
||||
|
||||
//profile.cpu(_ => Object.values(ao), 10000, "make array from objects");
|
||||
var dofn = function(x) { x += 1; }
|
||||
profile.cpu(_ => aa.forEach(dofn), 1000, "iterate array");
|
||||
profile.cpu(_ => ao.forEach(dofn), 1000, "iterate object foreach");
|
||||
profile.cpu(_ => {
|
||||
for (var i in ao) ao[i] += 1;
|
||||
}, 1000, "iterate in object values");
|
||||
*/
|
10
scripts/stdtest.js
Normal file
10
scripts/stdtest.js
Normal file
|
@ -0,0 +1,10 @@
|
|||
test.run("set transform scale", _ => {
|
||||
var t = os.make_transform();
|
||||
var s1 = t.scale.slice();
|
||||
t.scale = s1;
|
||||
return (t.scale.equal(s1));
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
|
@ -1,11 +1,23 @@
|
|||
/* Tests for prosperon */
|
||||
|
||||
var test = {};
|
||||
|
||||
var tests = [];
|
||||
var pass = 0;
|
||||
var fail = 0;
|
||||
var failed = [];
|
||||
|
||||
var test = function(name, fn)
|
||||
test.run_suite = function(file)
|
||||
{
|
||||
test = [];
|
||||
pass = 0;
|
||||
fail = 0;
|
||||
failed = [];
|
||||
|
||||
|
||||
}
|
||||
|
||||
test.run = function(name, fn)
|
||||
{
|
||||
var func = function() {
|
||||
print(`${pass+fail+1}/${tests.length}: ${name} ... `);
|
||||
|
@ -36,3 +48,5 @@ for (var f of failed)
|
|||
say(f);
|
||||
|
||||
os.quit();
|
||||
|
||||
return {test};
|
||||
|
|
|
@ -132,7 +132,8 @@ void render_init() {
|
|||
sg_setup(&(sg_desc){
|
||||
.environment = sglue_environment(),
|
||||
.logger = { .func = sg_logging },
|
||||
.buffer_pool_size = 1024
|
||||
.buffer_pool_size = 1024,
|
||||
.image_pool_size = 1024,
|
||||
});
|
||||
|
||||
std_sampler = sg_make_sampler(&(sg_sampler_desc){});
|
||||
|
|
Loading…
Reference in a new issue