Skip to content

Commit

Permalink
Added possibility to choose number of columns in performance test
Browse files Browse the repository at this point in the history
  • Loading branch information
javve committed Oct 27, 2011
1 parent 1e188bc commit a58c2cb
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 19 deletions.
4 changes: 2 additions & 2 deletions website/css/style.css
Expand Up @@ -462,8 +462,8 @@ h1 {
* * * * * * * * * * * * * * * * * * * * */

#size {
margin-left:200px;
width:390px;
margin-left:100px;
width:590px;
}
#time-table {
margin-bottom:40px;
Expand Down
50 changes: 33 additions & 17 deletions website/examples/performance-test.html
Expand Up @@ -119,17 +119,19 @@ <h2>Like what you see? Share it!</h2>
</div>

<div id="size">
<h2>How large list do you want to index?</h2>
<input type="text" value="1000" id="list-size" />
<h2>
How many <strong>items</strong> and with how many <strong>value names</strong>
do you want to index?
</h2>
<input type="text" value="1000" style="margin-left:60px;" id="list-size" />
<input type="text" value="3" style="width:40px;" id="column-count" />
<button class="btn" id="make-list">Make and index list</button>
</div>

<div class="c1">
<div id="performance-list" style="display:none;">
<input type="text" id="search-field" placeholder="Press enter to search" />
<span class="btn" id="sort-col-1">Sort column 1</span>
<span class="btn" id="sort-numbers">Sort column 2</span>
<span class="btn" id="sort-col-2">Sort column 3</span>
<div class="scroll-container c1">
<table>
<tbody class="list"></table>
Expand Down Expand Up @@ -160,6 +162,7 @@ <h2>Do you like what you see?</h2>
var theList,
sorted = false,
searched = false,
columnCount = 0,
timeTable = new List('time-table', { valueNames: ['operation', 'time' ], item: 'time-table-item'});

function randomString(length) {
Expand All @@ -178,19 +181,27 @@ <h2>Do you like what you see?</h2>

$('#make-list').click(createList);
$('#search-field').keypress(searchList);
$('#sort-col-1').click(function () { sortColumn('column1'); });
$('#sort-numbers').click(function () { sortColumn('column2'); });
$('#sort-col-2').click(function () { sortColumn('column3'); });
$('#sort-col-1').click(function () { sortColumn('column0'); });
/*
$('#sort-col-2').click(function () { sortColumn('column2'); });
$('#sort-col-3').click(function () { sortColumn('column3'); });
*/

$('#add-items').click(addItems);

/* CREATION */
function createList() {
var itemCount = +$('#list-size').val(),
htmlStuff = '';


columnCount = +$('#column-count').val();

for (var i = 0; i < itemCount; i++) {
htmlStuff += '<tr><td class="column1">'+randomString(13)+'</td><td class="column2">'+Math.floor(Math.random()*11000)+'</td><td class="column3">'+randomString(13)+'</td></tr>';
htmlStuff += '<tr>';
for (var j = 0; j < columnCount; j++) {
htmlStuff += '<td class="column'+j+'">'+randomString(13)+'</td>';
}
htmlStuff += '</tr>';
}
$('#performance-list .list').html(htmlStuff);

Expand All @@ -205,18 +216,23 @@ <h2>Do you like what you see?</h2>
function indexList() {
var itemCount = +$('#list-size').val(),
dateObj1,
dateObj2;
dateObj2,
valueNames = [];

for (var j = 0; j < columnCount; j++) {
valueNames.push('column'+j);
}

/* CREATE LIST PERFORMANCE */
dateObj1 = new Date();
theList = new List('performance-list', { valueNames: [ 'column1', 'column2', 'column3' ] });
theList = new List('performance-list', { valueNames: valueNames });
dateObj2 = new Date();

$('#list-size-val').text(theList.size());

$('#time-table').slideDown(function(){
timeTable.add({
operation: "Index list with "+itemCount+" items",
operation: "Index list with "+itemCount+" items and "+columnCount+" value names",
time: dateObj2.getTime() - dateObj1.getTime()
});
});
Expand Down Expand Up @@ -285,11 +301,11 @@ <h2>Do you like what you see?</h2>
var items = [];

for (var i = 0; i < numberOfItems; i++) {
items.push({
column1: randomString(13),
column2: Math.floor(Math.random()*11000),
column3: randomString(13)
});
var item = {};
for (var j = 0; j < columnCount; j++) {
item['column'+j] = randomString(13);
}
items.push(item);
}

/* ADD ITEMS TO LIST PERFORMANCE */
Expand Down

0 comments on commit a58c2cb

Please sign in to comment.