Skip to content

Commit

Permalink
Add some initial memory tests
Browse files Browse the repository at this point in the history
These can be executed using valgrind --tool=massif to get a rough idea of
memory behavior.  Valgrind massif using libc allocation primitives does
carry overhead that a proper pool allocator doesn't (they can be made
overhead free); but these numbers are still useful as guides.
  • Loading branch information
svaarala committed Jan 2, 2017
1 parent 0fe012a commit 6789c3f
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 0 deletions.
8 changes: 8 additions & 0 deletions tests/memory/test-function-expression-1.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
function test() {
var arr = [];
while (arr.length < 1e5) {
arr.push(function () {});
}
print(arr.length + ' anonymous functions created');
}
test();
11 changes: 11 additions & 0 deletions tests/memory/test-function-expression-2.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
function test() {
var arr = [];
var fn;
while (arr.length < 1e4) {
fn = function () {};
fn.prototype = null;
arr.push(fn);
}
print(arr.length + ' anonymous functions created');
}
test();
8 changes: 8 additions & 0 deletions tests/memory/test-plain-buffer-1.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
function test() {
var arr = [];
while (arr.length < 1e5) {
arr.push(Uint8Array.allocPlain(256));
}
print(arr.length + ' plain buffers created');
}
test();
8 changes: 8 additions & 0 deletions tests/memory/test-uint8array-1.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
function test() {
var arr = [];
while (arr.length < 1e5) {
arr.push(new Uint8Array(256));
}
print(arr.length + ' Uint8Arrays created');
}
test();

0 comments on commit 6789c3f

Please sign in to comment.