Skip to content

hyoo-ru/bench.hyoo.ru

Repository files navigation

$hyoo_bench

Common benchmarking interface, that can be added to any benchmarks.

Known benchmarks

Create your benchmark

Benchmark is html page, opened in iframe, and communicates with $hyoo_bench by RPC.

Benchmark must receive messages as array of values. First value is procedure name. Other values is procedure arguments.

window.addEventListener( 'message' , function( event ) {
	window[ event.data[0] ].apply( null , event.data.slice( 1 ) )
} )

To return result, benchmark must send message to parent frame.

function done( result ) {
	if( parent === window ) console.log( result )
	else parent.postMessage( [ 'done' , result ] , '*' )
}

At start $hyoo_bench sends [ 'meta' ] to get benchmark meta information in this format:

type meta = {
	title : { [ lang : string ] : string }
	descr : { [ lang : string ] : string }
	samples : { [ sample : string ] : {
		title : { [ lang : string ] : string }
	} }
	steps : { [ step : string ] : { 
		title : { [ lang : string ] : string }
	} }
	params : { [ param : string ] : {
		title : { [ lang : string ] : string }
		default : number
		type : string
		precision : number 
	} }
}

Description supports markdown. For every sample and step benchmark will receive message [ step , sample, params ].

Deploy benchmark to web server. In example: //localhost:9080/hyoo/bench/geometry/

Open $hyoo_bench_app and type in developer console command like this to switch to your benchmark:

$hyoo_bench_app.root(0).bench( '//localhost:9080/hyoo/bench/geometry/' )

Running custom benches from localhost

Pass url to benchmark in bench parameter to http://localhost:9080/hyoo/bench/app/

Example:

http://localhost:9080/hyoo/bench/app/#bench=..%2Fgeometry

Articles