News:

Please note these forums are mostly a testing ground for my SMF work and I don't really use them otherwise.

Main Menu

Paste-1327944527:v:use_geshi-1:v:type-php

Started by SleePy, Jan 30, 2012, 05:28 PM

Previous topic - Next topic

0 Members and 4 Guests are viewing this topic.

SleePy

<?php
if (isset($_SERVER[\'_\']))
   echo shell_exec($_SERVER[\'_\'] .\' -v | head -n 1\');
else
   echo `php -v | head -n 1`;
echo \"\\n\";

$array_size = 1000;
$array_data_size = 1000;
$loops = 1000;

$data = array();

for ($i = 0; $i < $array_size; $i++)
   $data[] = str_repeat(\'a\', $array_data_size);

$data_serialized = serialize($data);
$data_json = json_encode($data);

echo \'Array Size: \' . $array_size . \"\\n\";
echo \'Data Size: \' . $array_data_size . \"\\n\";
echo \'Loops to run: \' . $array_data_size . \"\\n\";

/******** SERIALIZE *************/
echo \"\\nSerialize: \";
$start = microtime(true);

for ($i = 0; $i < $loops; $i++)
   serialize($data);

$stop = microtime(true);
$diff = $stop - $start;

echo round($diff, 3) . \' (Start: \' . $stop . \' | Stop: \' . $start . \')\';


/******** JSON *************/
echo \"\\nJSON: \";
$start = microtime(true);

for ($i = 0; $i < $loops; $i++)
   json_encode($data);

$stop = microtime(true);
$diff = $stop - $start;

echo round($diff, 3) . \' (Start: \' . $stop . \' | Stop: \' . $start . \')\';


/******** SERIALIZE DECODE *************/
echo \"\\nSERIALIZE DECODE: \";
$start = microtime(true);

for ($i = 0; $i < $loops; $i++)
   json_encode($data_serialized);

$stop = microtime(true);
$diff = $stop - $start;

echo round($diff, 3) . \' (Start: \' . $stop . \' | Stop: \' . $start . \')\';


/******** JSON DECODE *************/
echo \"\\nJSON DECODE: \";
$start = microtime(true);

for ($i = 0; $i < $loops; $i++)
   json_encode($data_json);

$stop = microtime(true);
$diff = $stop - $start;

echo round($diff, 3) . \' (Start: \' . $stop . \' | Stop: \' . $start . \')\';

echo \"\\n\\n\";
No siggy! :D

SleePy

<?php
if (isset($_SERVER['_']))
   echo shell_exec($_SERVER['_'] .' -v | head -n 1');
else
   echo `php -v | head -n 1`;
echo "\n";

$array_size = 1000;
$array_data_size = 1000;
$loops = 1000;

$data = array();

for ($i = 0; $i < $array_size; $i++)
   $data[] = str_repeat('a', $array_data_size);

$data_serialized = serialize($data);
$data_json = json_encode($data);

echo 'Array Size: ' . $array_size . "\n";
echo 'Data Size: ' . $array_data_size . "\n";
echo 'Loops to run: ' . $array_data_size . "\n";

/******** SERIALIZE *************/
echo "\nSerialize: ";
$start = microtime(true);

for ($i = 0; $i < $loops; $i++)
   serialize($data);

$stop = microtime(true);
$diff = $stop - $start;

echo round($diff, 3) . ' (Start: ' . $stop . ' | Stop: ' . $start . ')';


/******** JSON *************/
echo "\nJSON: ";
$start = microtime(true);

for ($i = 0; $i < $loops; $i++)
   json_encode($data);

$stop = microtime(true);
$diff = $stop - $start;

echo round($diff, 3) . ' (Start: ' . $stop . ' | Stop: ' . $start . ')';


/******** SERIALIZE DECODE *************/
echo "\nSERIALIZE DECODE: ";
$start = microtime(true);

for ($i = 0; $i < $loops; $i++)
   json_encode($data_serialized);

$stop = microtime(true);
$diff = $stop - $start;

echo round($diff, 3) . ' (Start: ' . $stop . ' | Stop: ' . $start . ')';


/******** JSON DECODE *************/
echo "\nJSON DECODE: ";
$start = microtime(true);

for ($i = 0; $i < $loops; $i++)
   json_encode($data_json);

$stop = microtime(true);
$diff = $stop - $start;

echo round($diff, 3) . ' (Start: ' . $stop . ' | Stop: ' . $start . ')';

echo "\n\n";
No siggy! :D

SleePy

<?php
if (isset($_SERVER['_']))
   echo shell_exec($_SERVER['_'] .' -v | head -n 1');
else
   echo `php -v | head -n 1`;
echo "\n";

$array_size = 1000;
$array_data_size = 1000;
$loops = 1000;

$data = array();

for ($i = 0; $i < $array_size; $i++)
   $data[] = str_repeat('a', $array_data_size);

$data_serialized = serialize($data);
$data_json = json_encode($data);

echo 'Array Size: ' . $array_size . "\n";
echo 'Data Size: ' . $array_data_size . "\n";
echo 'Loops to run: ' . $array_data_size . "\n";

/******** SERIALIZE *************/
echo "\nSerialize: ";
$start = microtime(true);

for ($i = 0; $i < $loops; $i++)
   serialize($data);

$stop = microtime(true);
$diff = $stop - $start;

echo round($diff, 3) . ' (Start: ' . $stop . ' | Stop: ' . $start . ')';


/******** JSON *************/
echo "\nJSON: ";
$start = microtime(true);

for ($i = 0; $i < $loops; $i++)
   json_encode($data);

$stop = microtime(true);
$diff = $stop - $start;

echo round($diff, 3) . ' (Start: ' . $stop . ' | Stop: ' . $start . ')';


/******** SERIALIZE DECODE *************/
echo "\nSERIALIZE DECODE: ";
$start = microtime(true);

for ($i = 0; $i < $loops; $i++)
   json_encode($data_serialized);

$stop = microtime(true);
$diff = $stop - $start;

echo round($diff, 3) . ' (Start: ' . $stop . ' | Stop: ' . $start . ')';


/******** JSON DECODE *************/
echo "\nJSON DECODE: ";
$start = microtime(true);

for ($i = 0; $i < $loops; $i++)
   json_encode($data_json);

$stop = microtime(true);
$diff = $stop - $start;

echo round($diff, 3) . ' (Start: ' . $stop . ' | Stop: ' . $start . ')';

echo "\n\n";
No siggy! :D

SleePy

<?php
if (isset($_SERVER['_']))
   echo shell_exec($_SERVER['_'] .' -v | head -n 1');
else
   echo `php -v | head -n 1`;
echo "\n";

$array_size = 1000;
$array_data_size = 1000;
$loops = 1000;

$data = array();

for ($i = 0; $i < $array_size; $i++)
   $data[] = str_repeat('a', $array_data_size);

$data_serialized = serialize($data);
$data_json = json_encode($data);

echo 'Array Size: ' . $array_size . "\n";
echo 'Data Size: ' . $array_data_size . "\n";
echo 'Loops to run: ' . $array_data_size . "\n";

/******** SERIALIZE *************/
echo "\nSerialize: ";
$start = microtime(true);

for ($i = 0; $i < $loops; $i++)
   serialize($data);

$stop = microtime(true);
$diff = $stop - $start;

echo round($diff, 3) . ' (Start: ' . $stop . ' | Stop: ' . $start . ')';


/******** JSON *************/
echo "\nJSON: ";
$start = microtime(true);

for ($i = 0; $i < $loops; $i++)
   json_encode($data);

$stop = microtime(true);
$diff = $stop - $start;

echo round($diff, 3) . ' (Start: ' . $stop . ' | Stop: ' . $start . ')';


/******** SERIALIZE DECODE *************/
echo "\nSERIALIZE DECODE: ";
$start = microtime(true);

for ($i = 0; $i < $loops; $i++)
   json_encode($data_serialized);

$stop = microtime(true);
$diff = $stop - $start;

echo round($diff, 3) . ' (Start: ' . $stop . ' | Stop: ' . $start . ')';


/******** JSON DECODE *************/
echo "\nJSON DECODE: ";
$start = microtime(true);

for ($i = 0; $i < $loops; $i++)
   json_encode($data_json);

$stop = microtime(true);
$diff = $stop - $start;

echo round($diff, 3) . ' (Start: ' . $stop . ' | Stop: ' . $start . ')';

echo "\n\n";
No siggy! :D

SleePy

<?php
if (isset($_SERVER['_']))
   echo shell_exec($_SERVER['_'] .' -v | head -n 1');
else
   echo `php -v | head -n 1`;
echo "\n";

$array_size = 1000;
$array_data_size = 1000;
$loops = 1000;

$data = array();

for ($i = 0; $i < $array_size; $i++)
   $data[] = str_repeat('a', $array_data_size);

$data_serialized = serialize($data);
$data_json = json_encode($data);

echo 'Array Size: ' . $array_size . "\n";
echo 'Data Size: ' . $array_data_size . "\n";
echo 'Loops to run: ' . $array_data_size . "\n";

/******** SERIALIZE *************/
echo "\nSerialize(): ";
$start = microtime(true);

for ($i = 0; $i < $loops; $i++)
   serialize($data);

$stop = microtime(true);
$diff = $stop - $start;

echo round($diff, 3) . ' (Start: ' . $stop . ' | Stop: ' . $start . ')';


/******** JSON *************/
echo "\njson_encode(): ";
$start = microtime(true);

for ($i = 0; $i < $loops; $i++)
   json_encode($data);

$stop = microtime(true);
$diff = $stop - $start;

echo round($diff, 3) . ' (Start: ' . $stop . ' | Stop: ' . $start . ')';


/******** SERIALIZE DECODE *************/
echo "\nunserialize(): ";
$start = microtime(true);

for ($i = 0; $i < $loops; $i++)
   unserialize($data_serialized);

$stop = microtime(true);
$diff = $stop - $start;

echo round($diff, 3) . ' (Start: ' . $stop . ' | Stop: ' . $start . ')';


/******** JSON DECODE *************/
echo "\njson_decode(): ";
$start = microtime(true);

for ($i = 0; $i < $loops; $i++)
   json_decode($data_json);

$stop = microtime(true);
$diff = $stop - $start;

echo round($diff, 3) . ' (Start: ' . $stop . ' | Stop: ' . $start . ')';

echo "\n\n";
No siggy! :D