Skip to content

Commit

Permalink
Merge pull request #382 from softdevteam/more-type-stability
Browse files Browse the repository at this point in the history
Use typed arrays in Javascript runner.
  • Loading branch information
ltratt committed Jul 31, 2018
2 parents 5f9ec97 + 4cdc638 commit 8499097
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions iterations_runners/iterations_runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,22 +91,23 @@ load(BM_entry_point);
krun_init();
var BM_num_cores = krun_get_num_cores();

// Pre-allocate and fill arrays
var BM_wallclock_times = new Array(BM_n_iters);
BM_wallclock_times.fill(0);
// Pre-allocate and fill arrays.
// We use typed arrays to encourage type stability.
var BM_wallclock_times = new Float64Array(BM_n_iters);
BM_wallclock_times.fill(NaN);

var BM_cycle_counts = new Array(BM_num_cores);
var BM_aperf_counts = new Array(BM_num_cores);
var BM_mperf_counts = new Array(BM_num_cores);

for (BM_core = 0; BM_core < BM_num_cores; BM_core++) {
BM_cycle_counts[BM_core] = new Array(BM_n_iters);
BM_aperf_counts[BM_core] = new Array(BM_n_iters);
BM_mperf_counts[BM_core] = new Array(BM_n_iters);
BM_cycle_counts[BM_core] = new Float64Array(BM_n_iters);
BM_aperf_counts[BM_core] = new Float64Array(BM_n_iters);
BM_mperf_counts[BM_core] = new Float64Array(BM_n_iters);

BM_cycle_counts[BM_core].fill(0);
BM_aperf_counts[BM_core].fill(0);
BM_mperf_counts[BM_core].fill(0);
BM_cycle_counts[BM_core].fill(NaN);
BM_aperf_counts[BM_core].fill(NaN);
BM_mperf_counts[BM_core].fill(NaN);
}

// Main loop
Expand Down

0 comments on commit 8499097

Please sign in to comment.