Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

benchmark: fixed random value generation error #160

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions tests/benchmark/quicksort.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,16 @@
var SORTELEMENTS = 1e5;
var maximum = 0;
var minimum = 65536;
function rand(seed) {
var seed = 74755;

function rand() {
seed = (seed * 1309 + 13849) & 65535;
return seed;
}

function initArr(sortList) {
var seed = 74755;
for (var i = 1; i <= SORTELEMENTS; i++) {
sortList[i] = rand(seed);
sortList[i] = rand();
if (sortList[i] > maximum) {
maximum = sortList[i];
}
Expand Down
7 changes: 3 additions & 4 deletions tests/benchmark/quicksort.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,16 @@
const SORTELEMENTS = 1e5;
let maximum = 0;
let minimum = 65536;
let seed = 74755;

function rand(seed: number) {
function rand() {
seed = (seed * 1309 + 13849) & 65535;
return seed;
}

function initArr(sortList: number[]) {
const seed = 74755;

for (let i = 1; i <= SORTELEMENTS; i++) {
sortList[i] = rand(seed);
sortList[i] = rand();
if (sortList[i] > maximum) {
maximum = sortList[i];
} else if (sortList[i] < minimum) {
Expand Down
7 changes: 4 additions & 3 deletions tests/benchmark/quicksort_float.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@
var SORTELEMENTS = 1e5;
var maximum = 0;
var minimum = 65536;
function rand(seed) {
var seed = 74755;

function rand() {
seed = (seed * 1309 + 13849) & 65535;
return seed;
}
function initArr(sortList) {
var seed = 74755;
for (var i = 1; i <= SORTELEMENTS; i++) {
var val = rand(seed);
var val = rand();
sortList[i] = val + val / 65536;
if (sortList[i] > maximum) {
maximum = sortList[i];
Expand Down
5 changes: 3 additions & 2 deletions tests/benchmark/quicksort_float.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
const SORTELEMENTS = 1e5;
let maximum = 0;
let minimum = 65536;
let seed = 74755;

function rand(seed: number) {
function rand() {
seed = (seed * 1309 + 13849) & 65535;
return seed;
}
Expand All @@ -14,7 +15,7 @@ function initArr(sortList: number[]) {
const seed = 74755;

for (let i = 1; i <= SORTELEMENTS; i++) {
const val = rand(seed);
const val = rand();
sortList[i] = val + val / 65536;
if (sortList[i] > maximum) {
maximum = sortList[i];
Expand Down
Loading