Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
doctrine-dbal
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Tomáš Trávníček
doctrine-dbal
Commits
3b4de020
Commit
3b4de020
authored
May 27, 2007
by
zYne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
--no commit message
--no commit message
parent
514d67ef
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
71 additions
and
0 deletions
+71
-0
query_cache.php
benchmark/query_cache.php
+71
-0
No files found.
benchmark/query_cache.php
0 → 100644
View file @
3b4de020
<?php
require_once
'../lib/Doctrine.php'
;
spl_autoload_register
(
array
(
'Doctrine'
,
'autoload'
));
class
Entity
extends
Doctrine_Record
{
public
function
setTableDefinition
()
{
$this
->
hasColumn
(
'id'
,
'integer'
,
20
,
'autoincrement|primary'
);
$this
->
hasColumn
(
'name'
,
'string'
,
50
);
}
}
$dbh
=
new
Doctrine_Db
(
'sqlite:test.db'
);
$conn
=
Doctrine_Manager
::
getInstance
()
->
openConnection
(
$dbh
);
// initialize some entities
$coll
=
new
Doctrine_Collection
(
'Entity'
);
$i
=
10
;
while
(
$i
--
)
{
$coll
[
$i
]
->
name
=
'e '
.
$i
;
}
$coll
->
save
();
$conn
->
clear
();
$timepoint
=
microtime
(
true
);
$i
=
100
;
$query
=
new
Doctrine_Query
();
$query
->
setOption
(
'resultSetCache'
,
new
Doctrine_Cache_Array
());
while
(
$i
--
)
{
$query
->
from
(
'Entity e'
)
->
where
(
'e.id > 0'
);
$coll
=
$query
->
execute
(
array
(),
Doctrine
::
FETCH_ARRAY
);
}
print
'EXECUTED 100 QUERIES WITH CACHING ENABLED + FETCH_ARRAY : '
.
(
microtime
(
true
)
-
$timepoint
)
.
"<br \>"
;
$timepoint
=
microtime
(
true
);
$i
=
100
;
while
(
$i
--
)
{
$query
=
new
Doctrine_Query
();
$query
->
from
(
'Entity e'
)
->
where
(
'e.id > 0'
);
$coll
=
$query
->
execute
(
array
(),
Doctrine
::
FETCH_ARRAY
);
}
print
'EXECUTED 100 QUERIES WITHOUT CACHING + FETCH_ARRAY : '
.
(
microtime
(
true
)
-
$timepoint
);
$timepoint
=
microtime
(
true
);
$i
=
100
;
$query
=
new
Doctrine_Query
();
$query
->
setOption
(
'resultSetCache'
,
new
Doctrine_Cache_Array
());
while
(
$i
--
)
{
$query
->
from
(
'Entity e'
)
->
where
(
'e.id > 0'
);
$coll
=
$query
->
execute
();
}
print
'EXECUTED 100 QUERIES WITH CACHING ENABLED + FETCH_RECORD : '
.
(
microtime
(
true
)
-
$timepoint
)
.
"<br \>"
;
$timepoint
=
microtime
(
true
);
$i
=
100
;
while
(
$i
--
)
{
$query
=
new
Doctrine_Query
();
$query
->
from
(
'Entity e'
)
->
where
(
'e.id > 0'
);
$coll
=
$query
->
execute
();
}
print
'EXECUTED 100 QUERIES WITHOUT CACHING + FETCH_RECORD : '
.
(
microtime
(
true
)
-
$timepoint
);
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment