<commit_before><?php

set_include_path(dirname(__FILE__) . '/../../../../');

$mark = microtime(true);

require_once('limb/core/common.inc.php');
require_once('limb/active_record/common.inc.php');

echo "active record common includes: " . (microtime(true) - $mark) . "\n";

if($native_db = sqlite_open('/tmp/benchdb'))
{
  sqlite_query($native_db, 'CREATE TABLE foo (bar varchar(10))');
  sqlite_query($native_db, "INSERT INTO foo VALUES ('some value')");
}

$mark = microtime(true);

for($i=0;$i<1000;$i++)
{
  $query = sqlite_query($native_db, 'SELECT bar FROM foo');
  while($entry = sqlite_fetch_array($query, SQLITE_ASSOC))
   $bar = $entry['bar'];
}

echo "native sqlite fetching: " . (microtime(true) - $mark) . "\n";

$conn = lmbDBAL :: newConnection('sqlite://localhost//tmp/benchdb');
$mark = microtime(true);

for($i=0;$i<1000;$i++)
{
  $rs = lmbDBAL :: fetch('SELECT bar FROM foo', $conn);
  foreach($rs as $record)
   $bar = $record->get('bar');
}

echo "lmbDBAL :: fetch(), getter: " . (microtime(true) - $mark) . "\n";

class Foo extends lmbActiveRecord{}

lmbActiveRecord :: setDefaultDSN('sqlite://localhost//tmp/benchdb'); 

$mark = microtime(true);

for($i=0;$i<1000;$i++)
{
  $rs = lmbActiveRecord :: find('Foo');
  foreach($rs as $obj)
    $foo = $obj->get('foo');
}

echo "lmbActiveRecord fetching, getter: " . (microtime(true) - $mark) . "\n";

$mark = microtime(true);

for($i=0;$i<1000;$i++)
{
  $rs = lmbActiveRecord :: find('Foo');
  foreach($rs as $obj)
    $foo = $obj->foo;
}

echo "lmbActiveRecord fetching, attr access: " . (microtime(true) - $mark) . "\n";

$mark = microtime(true);

for($i=0;$i<1000;$i++)
{
  $rs = Foo :: find();
  foreach($rs as $obj)
    $foo = $obj->get('foo');
}

echo "Foo fetching, getter: " . (microtime(true) - $mark) . "\n";

unlink('/tmp/benchdb');<commit_msg>[svn r6406] -- bench typos fixes<commit_after><?php

set_include_path(dirname(__FILE__) . '/../../../../');

$mark = microtime(true);

require_once('limb/core/common.inc.php');
require_once('limb/active_record/common.inc.php');

echo "active record common includes: " . (microtime(true) - $mark) . "\n";

if($native_db = sqlite_open('/tmp/benchdb'))
{
  sqlite_query($native_db, 'CREATE TABLE foo (bar varchar(10))');
  sqlite_query($native_db, "INSERT INTO foo VALUES ('some value')");
}

$mark = microtime(true);

for($i=0;$i<1000;$i++)
{
  $query = sqlite_query($native_db, 'SELECT bar FROM foo');
  while($entry = sqlite_fetch_array($query, SQLITE_ASSOC))
   $bar = $entry['bar'];
}

echo "native sqlite fetching: " . (microtime(true) - $mark) . "\n";

$conn = lmbDBAL :: newConnection('sqlite://localhost//tmp/benchdb');
$mark = microtime(true);

for($i=0;$i<1000;$i++)
{
  $rs = lmbDBAL :: fetch('SELECT bar FROM foo', $conn);
  foreach($rs as $record)
   $bar = $record->get('bar');
}

echo "lmbDBAL :: fetch(), getter: " . (microtime(true) - $mark) . "\n";

class Foo extends lmbActiveRecord{}

lmbActiveRecord :: setDefaultDSN('sqlite://localhost//tmp/benchdb'); 

$mark = microtime(true);

for($i=0;$i<1000;$i++)
{
  $rs = lmbActiveRecord :: find('Foo');
  foreach($rs as $obj)
    $foo = $obj->get('bar');
}

echo "lmbActiveRecord fetching, getter: " . (microtime(true) - $mark) . "\n";

$mark = microtime(true);

for($i=0;$i<1000;$i++)
{
  $rs = lmbActiveRecord :: find('Foo');
  foreach($rs as $obj)
    $foo = $obj->bar;
}

echo "lmbActiveRecord fetching, attr access: " . (microtime(true) - $mark) . "\n";

$mark = microtime(true);

for($i=0;$i<1000;$i++)
{
  $rs = Foo :: find();
  foreach($rs as $obj)
    $foo = $obj->get('bar');
}

echo "Foo fetching, getter: " . (microtime(true) - $mark) . "\n";

unlink('/tmp/benchdb');
{'fraction_non_alphanumeric': 0.23095823095823095, 'fraction_numerical': 0.015834015834015835, 'mean_word_length': 4.485029940119761, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4902619', 'n_tokens_mistral': 1493, 'n_tokens_neox': 1420, 'n_words': 277}