Skip to content

Add benchmarks for recent changes #1838

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

Closed
wants to merge 8 commits into from
Closed
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
84 changes: 84 additions & 0 deletions perf/Set.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
/**
* Copyright (c) 2014-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

describe('Set', () => {
describe('maps with changes', () => {
const array2 = [];
for (let i = 0; i < 2; i++) {
array2[i] = i;
}
const set2 = Immutable.Set(array2);
it('of 2', () => {
set2.map((value) => value + 1);
});

const array8 = [];
for (let i = 0; i < 8; i++) {
array8[i] = i;
}
const set8 = Immutable.Set(array8);
it('of 8', () => {
set8.map((value) => value + 1);
});

const array32 = [];
for (let i = 0; i < 32; i++) {
array32[i] = i;
}
const set32 = Immutable.Set(array32);
it('of 32', () => {
set32.map((value) => value + 1);
});

const array1024 = [];
for (let i = 0; i < 1024; i++) {
array1024[i] = i;
}
const set1024 = Immutable.Set(array1024);
it('of 1024', () => {
set1024.map((value) => value + 1);
});
});

describe('maps without changes', () => {
const array2 = [];
for (let i = 0; i < 2; i++) {
array2[i] = i;
}
const set2 = Immutable.Set(array2);
it('of 2', () => {
set2.map((value) => value);
});

const array8 = [];
for (let i = 0; i < 8; i++) {
array8[i] = i;
}
const set8 = Immutable.Set(array8);
it('of 8', () => {
set8.map((value) => value);
});

const array32 = [];
for (let i = 0; i < 32; i++) {
array32[i] = i;
}
const set32 = Immutable.Set(array32);
it('of 32', () => {
set32.map((value) => value);
});

const array1024 = [];
for (let i = 0; i < 1024; i++) {
array1024[i] = i;
}
const set1024 = Immutable.Set(array1024);
it('of 1024', () => {
set1024.map((value) => value);
});
});
});
52 changes: 52 additions & 0 deletions perf/fromJS.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/**
* Copyright (c) 2014-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

describe('fromJS', () => {
const list = Immutable.List();
it('List', () => {
Immutable.fromJS(list);
});

const object = { foo: 'bar' };
it('object', () => {
Immutable.fromJS(object);
});

describe('array of Lists', () => {
const array2 = [];
for (let i = 0; i < 2; i++) {
array2[i] = Immutable.List();
}
it('of 2', () => {
Immutable.fromJS(array2);
});

const array8 = [];
for (let i = 0; i < 8; i++) {
array8[i] = Immutable.List();
}
it('of 8', () => {
Immutable.fromJS(array8);
});

const array32 = [];
for (let i = 0; i < 32; i++) {
array32[i] = Immutable.List();
}
it('of 32', () => {
Immutable.fromJS(array32);
});

const array1024 = [];
for (let i = 0; i < 1024; i++) {
array1024[i] = i;
}
it('of 1024', () => {
Immutable.fromJS(array1024);
});
});
});
48 changes: 48 additions & 0 deletions perf/hash.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/**
* Copyright (c) 2014-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

describe('hash', () => {
const aString = 'test';
it('a string', () => {
Immutable.hash(aString);
});

const aNumber = 5;
it('a number', () => {
Immutable.fromJS(aNumber);
});

const aNull = null;
it('null', () => {
Immutable.hash(aNull);
});

const anUndefined = undefined;
it('undefined', () => {
Immutable.hash(anUndefined);
});

const aBoolean = true;
it('a boolean', () => {
Immutable.hash(aBoolean);
});

const anObject = {};
it('an object', () => {
Immutable.hash(anObject);
});

const anArray = [];
it('an array', () => {
Immutable.hash(anArray);
});

const aFunction = () => null;
it('a function', () => {
Immutable.hash(aFunction);
});
});
4 changes: 2 additions & 2 deletions perf/toJS.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ describe('toJS', () => {
const list = Immutable.List(array32);

it('List of 32', () => {
Immutable.toJS(list);
list.toJS(list);
});

const obj32 = {};
Expand All @@ -23,6 +23,6 @@ describe('toJS', () => {
const map = Immutable.Map(obj32);

it('Map of 32', () => {
Immutable.toJS(map);
map.toJS(map);
});
});