From e82994582a7d6a0c0a9e800d8102770ecc326d57 Mon Sep 17 00:00:00 2001 From: Futago-za Ryuu Date: Fri, 15 Feb 2019 11:50:12 +0000 Subject: [PATCH] Use files from repo during benchmark in a browser --- tools/benchmark/browser.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/tools/benchmark/browser.js b/tools/benchmark/browser.js index 36056e1..781dc76 100644 --- a/tools/benchmark/browser.js +++ b/tools/benchmark/browser.js @@ -5,6 +5,9 @@ const Runner = require( "./runner.js" ); const benchmarks = require( "./benchmarks.js" ); +let BRANCH = location.hash.match( /branch=([^&]*)/i ); +BRANCH = BRANCH ? BRANCH[ 1 ] : "master"; + $( "#run" ).click( () => { // Results Table Manipulation @@ -75,9 +78,11 @@ $( "#run" ).click( () => { readFile( file ) { + if ( file.indexOf( "benchmark" ) === 0 ) file = "tools" + file; + return $.ajax( { type: "GET", - url: "/" + file, + url: `https://raw.githubusercontent.com/pegjs/pegjs/${ BRANCH }/` + file, dataType: "text", async: false } ).responseText; @@ -105,7 +110,7 @@ $( "#run" ).click( () => { resultsTable.append( ` - ${ benchmark.title } + ${ benchmark.title } " ` );