<?php
$teststime_start = microtime_float();
$totaltime = 0;
echo stats();
echo "Import List (Memory Jump)";
include('list.php');
echo stats();
include("_classes/class.csvlist.php");
$list = new csvlist();
/* //Generate own list
for($i = 0; $i < 10000; $i++)
{
$random_number = mt_rand(0,9) . mt_rand(0,9) . mt_rand(0,9) . mt_rand(0,9) . mt_rand(0,9). mt_rand(0,9). mt_rand(0,9). mt_rand(0,9). mt_rand(0,9);
echo "<br/>Loop : $i : $random_number ";
$list->add($random_number);
}
*/
//Import Existing list
echo "<br/>String Length : ".strlen($thislist);
$list->import($thislist);
echo "<br/>Mem : Imported List.";
echo stats();
unset($thislist); //Memory Saving
//Adding to the back of the list
echo "<br/> Adding '374312159' to the back of the list";
$list->add("374312159");
echo stats();
//Adding to the front of the list (using true)
echo "<br/> Adding '21' to the front of the list (Slower then back)";
$list->add("21,",true);
echo stats();
//Adding an existing item to list
$list->add("374312159"); //This will cause an error as it exists
echo "<br/>Trying to add 374312159 -> Error due to adding unique item 374312159 >> ".$list->display_error();
echo stats();
//Searching
echo "<br/> Running a search for \"%32543\" (More results = slower)";
echo "<br/> Similar to SQL use '%' for front/back matching ie %123 (ending with 123) or 123% (starting with 123) or %123%";
$x = $list->search("%3254");
echo " found ".count($x)." matches. <br/>";
print_r($x);
echo stats();
//Removing
echo "<br/> Removing record '374312159'";
$list->remove(374312159);
echo stats();
//Retrieving Record range
echo "<br/> Retrieving Record range (From front-back) ";
$a = $list->get_records(0,10);
print_r($a);
echo stats();
//Retrieving Record range (Reverse)
echo "<br/> Retrieving Record range (From back-front)";
$a = $list->get_records(0,10,true);
print_r($a);
echo stats();
echo "</br><br/><br/>";
echo "</br><br/><br/>";
//print_r($list->list);
echo "<br/><br/> No of items in List : ".$list->count_item();
echo "<br/>MAX MEM USED :".memory_get_peak_usage();
echo stats();
//CSV format
function stats()
{
$time_end = microtime_float();
$time = $time_end - $GLOBALS[teststime_start];
$time *= 1000;
$GLOBALS[totaltime] += $time;
echo "<br/>Memory Usage : ".memory_get_usage()." -- Time taken: ".round($time,3)." ms -- Total Time lasped: ".round($GLOBALS[totaltime],3)."ms<br/>";
$GLOBALS[teststime_start] = microtime_float();
}
function microtime_float()
{
list($usec, $sec) = explode(" ", microtime());
return ((float)$usec + (float)$sec);
}
?>