404 Page not found
Page not found, sorry.
├── .gitignore ├── docs ├── extra-styles.css ├── favicon.ico ├── triangle-closed.png ├── triangle-opened.png ├── bootstrap │ ├── img │ │ ├── glyphicons-halflings.png │ │ └── glyphicons-halflings-white.png │ ├── css │ │ ├── bootstrap-select.min.css │ │ ├── bootstrap-responsive.min.css │ │ └── bootstrap-responsive.css │ └── js │ │ ├── bootstrap-select.min.js │ │ └── bootstrap.min.js ├── nav.js ├── highlighter.css ├── highlighter.js ├── 404.html ├── index.html ├── haxe-nav.css ├── benched │ ├── Benched.html │ └── BenchmarkResults.html ├── index.js └── styles.css ├── samples.hxml ├── dox.hxml ├── haxelib.json ├── CHANGELOG.md ├── samples └── Fib.hx ├── README.md ├── src └── benched │ ├── BenchmarkResults.hx │ └── Benched.hx └── LICENSE /.gitignore: -------------------------------------------------------------------------------- 1 | bin/ 2 | *.hxs -------------------------------------------------------------------------------- /docs/extra-styles.css: -------------------------------------------------------------------------------- 1 | /** to be overridden in sub-themes */ -------------------------------------------------------------------------------- /docs/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hamaluik/benched/master/docs/favicon.ico -------------------------------------------------------------------------------- /docs/triangle-closed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hamaluik/benched/master/docs/triangle-closed.png -------------------------------------------------------------------------------- /docs/triangle-opened.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hamaluik/benched/master/docs/triangle-opened.png -------------------------------------------------------------------------------- /samples.hxml: -------------------------------------------------------------------------------- 1 | -cp src 2 | -cp samples 3 | -dce full 4 | -main Fib 5 | --js bin/fib.js 6 | -lib hxnodejs 7 | --cmd node bin/fib.js -------------------------------------------------------------------------------- /docs/bootstrap/img/glyphicons-halflings.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hamaluik/benched/master/docs/bootstrap/img/glyphicons-halflings.png -------------------------------------------------------------------------------- /docs/bootstrap/img/glyphicons-halflings-white.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hamaluik/benched/master/docs/bootstrap/img/glyphicons-halflings-white.png -------------------------------------------------------------------------------- /dox.hxml: -------------------------------------------------------------------------------- 1 | -cp src 2 | 3 | benched.Benched 4 | benched.BenchmarkResults 5 | 6 | -D doc-gen 7 | -xml docs/dox.xml 8 | 9 | --next 10 | -cmd haxelib run dox -i docs -o docs --title "Benched" --toplevel-package "benched" -D version "0.2.0" -D source-path "https://github.com/hamaluik/benched/tree/master/src" -D description "A statistics-based benchmarking tool for Haxe, inspired by criterion" -------------------------------------------------------------------------------- /docs/nav.js: -------------------------------------------------------------------------------- 1 | var navContent='
'; -------------------------------------------------------------------------------- /haxelib.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "benched", 3 | "url" : "https://github.com/hamaluik/benched", 4 | "license": "Apache", 5 | "classPath": "src", 6 | "tags": ["cross", "utility"], 7 | "description": "A statistics-based benchmarking tool for Haxe, inspired by criterion", 8 | "version": "0.2.0", 9 | "releasenote": "Better output formatting, especially for changes", 10 | "contributors": ["hamaluik"], 11 | "dependencies": {} 12 | } 13 | -------------------------------------------------------------------------------- /docs/highlighter.css: -------------------------------------------------------------------------------- 1 | /** 2 | Code Highlighting 3 | **/ 4 | html pre, html pre code { 5 | font-family: consolas, monospace; 6 | white-space: pre; 7 | overflow-x: auto; 8 | } 9 | code { 10 | color: #333; 11 | } 12 | code a { 13 | color: #08c; 14 | } 15 | pre { 16 | color: #333; 17 | margin: 15px 0; 18 | padding: 0.5em; 19 | } 20 | pre .type { 21 | color: #0086b3; 22 | } 23 | pre .kwd { 24 | color: #00a; 25 | } 26 | pre .val { 27 | color: #44a; 28 | } 29 | pre .str, div.pre .str, pre .str .kwd, pre .str .val, pre .str .type { 30 | color: #a00; 31 | } 32 | pre .cmt { 33 | color: #008800; 34 | color: #998; 35 | font-style: italic; 36 | } 37 | /* Make sure keywords inside comments are not highlighted*/ 38 | pre .cmt .kwd, pre .cmt .str, pre .cmt .val, pre .cmt .type { 39 | color: #998; 40 | } 41 | .last-modified { 42 | color:#999; 43 | } 44 | .semantic { 45 | display:none; 46 | } 47 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | All notable changes to this project will be documented in this file. 3 | 4 | The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), 5 | and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). 6 | 7 | ## [0.2.0]—2020-02-18 8 | ### Added 9 | - Added a function (`percentDifference`) to `BenchmarkResults` to calculate percent 10 | differences between result sets 11 | - Made `floatToStringPrecision` and `displayEng` functions in `BenchmarkResults` 12 | public if you want to use them for whatever reason 13 | 14 | ### Changed 15 | - Changed formatting of markdown tables in reports to be more well-formatted 16 | - Tidied up the `Fib` sample a bit to be more consistent between README and implementation 17 | 18 | ## [0.1.0]—2020-02-16 19 | - Initial release 20 | 21 | [Unreleased]: https://github.com/hamaluik/headbutt/compare/v0.6.0...HEAD 22 | [0.2.0]: https://github.com/hamaluik/headbutt/compare/v0.1.0...v0.2.0 23 | [0.1.0]: https://github.com/hamaluik/headbutt/releases/tag/v0.1.0 24 | -------------------------------------------------------------------------------- /docs/highlighter.js: -------------------------------------------------------------------------------- 1 | // highlighter adapted/modified from code.haxe.org 2 | (function (console) { "use strict"; 3 | var EReg = function(r,opt) { 4 | opt = opt.split("u").join(""); 5 | this.r = new RegExp(r,opt); 6 | }; 7 | EReg.prototype = { 8 | replace: function(s,by) { 9 | return s.replace(this.r,by); 10 | } 11 | }; 12 | var Highlighter = function() { }; 13 | Highlighter.main = function() { 14 | var _g = 0; 15 | var _g1 = window.document.body.querySelectorAll("pre code"); 16 | while(_g < _g1.length) { 17 | var el = _g1[_g]; 18 | ++_g; 19 | if(!Highlighter.hasClass(el,"highlighted")) { 20 | el.innerHTML = Highlighter.syntaxHighlight(el.innerHTML); 21 | el.className += " highlighted"; 22 | } 23 | } 24 | }; 25 | Highlighter.hasClass = function(el,className) { 26 | return el.className.indexOf(className) != -1; 27 | }; 28 | Highlighter.syntaxHighlight = function(html) { 29 | var kwds = ["abstract","trace","break","case","cast","class","continue","default","do","dynamic","else","enum","extends","extern","for","function","if","implements","import","in","inline","interface","macro","new","override","package","private","public","return","static","switch","throw","try","typedef","untyped","using","var","while"]; 30 | var kwds1 = new EReg("\\b(" + kwds.join("|") + ")\\b","g"); 31 | var vals = ["null","true","false","this"]; 32 | var vals1 = new EReg("\\b(" + vals.join("|") + ")\\b","g"); 33 | var types = new EReg("\\b([A-Z][a-zA-Z0-9]*)\\b","g"); 34 | html = kwds1.replace(html,"$1"); 35 | html = vals1.replace(html,"$1"); 36 | html = types.replace(html,"$1"); 37 | html = new EReg("(\"[^\"]*\")","g").replace(html,"$1"); 38 | html = new EReg("(//.+?)(\n|$)","g").replace(html,"$1$2"); 39 | html = new EReg("(/\\*\\*?(.|\n)+?\\*?\\*/)","g").replace(html,"$1"); 40 | return html; 41 | }; 42 | Highlighter.main(); 43 | })(typeof console != "undefined" ? console : {log:function(){}}); 44 | -------------------------------------------------------------------------------- /samples/Fib.hx: -------------------------------------------------------------------------------- 1 | import haxe.Unserializer; 2 | import haxe.Serializer; 3 | import benched.Benched; 4 | 5 | class Fib { 6 | static function fibonacci_naive(n: Int): Int { 7 | return switch n { 8 | case 0: 1; 9 | case 1: 1; 10 | case n: fibonacci_naive(n - 1) + fibonacci_naive(n - 2); 11 | } 12 | } 13 | 14 | static function fibonacci_optimized(n: Int): Int { 15 | var a: Int = 0; 16 | var b: Int = 1; 17 | 18 | return switch(n) { 19 | case 0: b; 20 | case _: { 21 | for(_ in 0...n) { 22 | var c = a + b; 23 | a = b; 24 | b = c; 25 | } 26 | b; 27 | } 28 | } 29 | } 30 | 31 | public static function main() { 32 | // first run our naive benchmark and serialize it 33 | // let's pretend we ran this before writing `fibonacci_optimized` 34 | var bencher = new Benched(); 35 | bencher.benchmark("Fibonacci(1)", () -> fibonacci_naive(1)); 36 | bencher.benchmark("Fibonacci(5)", () -> fibonacci_naive(5)); 37 | bencher.benchmark("Fibonacci(10)", () -> fibonacci_naive(10)); 38 | var s = new Serializer(); 39 | s.serialize(bencher); 40 | sys.io.File.saveContent("_fib_naive.hxs", s.toString()); 41 | Sys.println('### Naive Implementation'); 42 | Sys.println(bencher.generateReport()); 43 | 44 | // ... some time passes ... 45 | 46 | // now we've made some changes to our fibonacci calculator (`fibonacci_optimized`) 47 | // benchmark the results 48 | var bencher = new Benched(); 49 | bencher.benchmark("Fibonacci(1)", () -> fibonacci_optimized(1)); 50 | bencher.benchmark("Fibonacci(5)", () -> fibonacci_optimized(5)); 51 | bencher.benchmark("Fibonacci(10)", () -> fibonacci_optimized(10)); 52 | Sys.println('### Optimized Implementation'); 53 | Sys.println(bencher.generateReport()); 54 | 55 | // now load our old results and see if we made things faster 56 | var oldBencher: Benched = new Unserializer(sys.io.File.getContent("_fib_naive.hxs")).unserialize(); 57 | Sys.println("### Changes"); 58 | Sys.println(bencher.generateComparisonReport(oldBencher)); 59 | } 60 | } -------------------------------------------------------------------------------- /docs/404.html: -------------------------------------------------------------------------------- 1 |Page not found, sorry.
A statistics-based benchmarking tool for Haxe, inspired by criterion
| Benched | Utility to run benchmarks and collect samples |
| BenchmarkResults | A collection of values representing a timing sample |
Utility to run benchmarks and collect samples
new (minSecondsPerSample:Float = 0.5, samplesPerBenchmark:Int = 50, verbose:Bool = false)Create a new benchmark suite
Parameters:
minSecondsPerSample | how much time must accumulate by repeating the benchmark until a sample is counted |
|---|---|
samplesPerBenchmark | how many samples to collect per benchmark |
verbose | whether or not to print progress information |
benchmark (name:String, f:Void ‑> Void):BenchmarkResultsBenchmark the function f, storing the results to be processed later.
10 | Note: f should be as pure as possible, because it will be run
11 | numerous times so as to collect enough sampling data
Parameters:
name | the name of the benchmark |
|---|---|
f | a callback to benchmark with |
Returns:
BenchmarkResults
generateComparisonReport (old:Benched):StringIf you change your code and generate a new benchmark, use this to compare the changes to see if the changes had
12 | a statistically significant effect. Generally this is done by serializing a Benched instance, changing the code,
13 | re-running benchmarks, and then deserializing the old benchmarks, and supplying them to this function. This generates
14 | a Markdown table similar to generateReport()
15 | but with more columns of details.
Parameters:
old | The previous run of the same benchmarks, with possibly different implementations |
|---|
Returns:
String
A collection of values representing a timing sample
isMeanDifferent (this:Array<Float>):BoolCalculate whether the means of the two results are statistically different
10 | with α = 0.05 (p = 0.95). Returns true if the means are statistically
11 | different
Parameters:
other | the other result to compare against. |
|---|
Returns:
Bool
percentDifference (this:Array<Float>):FloatCalculate the % difference (0―100) between this benchmark and the other, 12 | using the other as the basis for comparison
Parameters:
other | the other / old benchmark to compare against |
|---|
Returns:
Float
toString ():StringDisplay the results as the mean timing with an error, both in engineering notation
Returns:
String
staticfloatToStringPrecision (n:Float, prec:Int):StringUtility to convert a float to a given precision with padded 0's
Parameters:
n | the number to convert |
|---|---|
prec | the number of decimal places to display |
See: