Skip to content
This repository was archived by the owner on Mar 30, 2025. It is now read-only.

created optimized versions, added unit tests, new benchmarks #2

Open
wants to merge 21 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ If you are not familiar with MongoDb, take a look at a given expression object a
##USAGE:
[USAGE.md](USAGE.md)

##TESTING:
[TESTING.md](TESTING.md)

##BENCHMARKS:
[benchmarks/README.md](benchmarks/README.md)

##FAQ:
###Why not write to MongoDB?
This is a raw PHP implementation that works without MongoDB, check out profiling information and use MongoDB in most cases(excluding those when you definetly don't need a database).
Expand Down
5 changes: 5 additions & 0 deletions TESTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Unit testing
============
put EnhanceTestFramework.php (http://enhance-php.com) into ./enhance folder and run unit_test.php

The unit tests have been created based on enhance-php version 2.1.4, which is not given here because of possible updates.
43 changes: 43 additions & 0 deletions benchmarks/ArrayQuery.bench.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php
include('../data/data_big.php');
include('../src/ArrayQuery.class.php');
$loops=100;
$s = new ArrayQuery($array);
for ($i=0; $i<$loops; $i++) {
$d = $s->find(array("release.year" => 2013));
$d = $s->find(array("release.arch"=>"x86"));
$d = $s->find(array("release.arch" => array('$regex' => "/4$/")));
$queryArray = array(
"release" => array(
"arch" => "x86"
)
);
//$d = $s->find($s->convert($queryArray));
$d = $s->convert($queryArray);
$d = $s->find(array(
"release.version" => array(
'$mod' => array(
23 => 0
)
)
));
$d = $s->find(array(
"release.arch" => array(
'$size' => 2
)
));
$d = $s->find(array(
"release.arch" => array(
'$all' => array(
"x86",
"x64"
)
)
));
$d = $s->find(array(
"release" => array(
'$has' => "x86"
)
));
}
?>
43 changes: 43 additions & 0 deletions benchmarks/ArrayQuery_goto.bench.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php
include('../data/data_big.php');
include('../src/ArrayQuery_goto.class.php');
$loops=100;
$s = new ArrayQuery_goto($array);
for ($i=0; $i<$loops; $i++) {
$d = $s->find(array("release.year" => 2013));
$d = $s->find(array("release.arch"=>"x86"));
$d = $s->find(array("release.arch" => array('$regex' => "/4$/")));
$queryArray = array(
"release" => array(
"arch" => "x86"
)
);
//$d = $s->find($s->convert($queryArray));
$d = $s->convert($queryArray);
$d = $s->find(array(
"release.version" => array(
'$mod' => array(
23 => 0
)
)
));
$d = $s->find(array(
"release.arch" => array(
'$size' => 2
)
));
$d = $s->find(array(
"release.arch" => array(
'$all' => array(
"x86",
"x64"
)
)
));
$d = $s->find(array(
"release" => array(
'$has' => "x86"
)
));
}
?>
43 changes: 43 additions & 0 deletions benchmarks/ArrayQuery_goto_micro.bench.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php
include('../data/data_big.php');
include('../src/ArrayQuery_goto_micro.class.php');
$loops=100;
$s = new ArrayQuery_goto_micro($array);
for ($i=0; $i<$loops; $i++) {
$d = $s->find(array("release.year" => 2013));
$d = $s->find(array("release.arch"=>"x86"));
$d = $s->find(array("release.arch" => array('$regex' => "/4$/")));
$queryArray = array(
"release" => array(
"arch" => "x86"
)
);
//$d = $s->find($s->convert($queryArray));
$d = $s->convert($queryArray);
$d = $s->find(array(
"release.version" => array(
'$mod' => array(
23 => 0
)
)
));
$d = $s->find(array(
"release.arch" => array(
'$size' => 2
)
));
$d = $s->find(array(
"release.arch" => array(
'$all' => array(
"x86",
"x64"
)
)
));
$d = $s->find(array(
"release" => array(
'$has' => "x86"
)
));
}
?>
Loading