Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 56 lines (47 sloc) 1.96 kb
ea9f4ccb »
2010-04-19 Readme added
1 Hello. This is a PHP5 benchmarking class.
2
3 WHY?
4 ====
5 Often there are two or more ways to do the same thing. Sometimes they
6 both are nice to write. The key criterion is now: performance. But
7 how to test the performance of an PHP code? I'm tired of writing a loop
8 for many executations and using microtime(true).
9
10 So I've written a class which is able to do this.
11
12 HOW?
13 ====
14 This class supports two ways of performance comparison:
15 - The class calls a given function e.g. 10'000 times and clocks the
16 time needed.
17 - The class calls a given function permanently until X seconds
18 running time reached and counts the number of started calls.
19
20 In benchmarks/example.php you can find an working example, which
21 compares the „switch“ structure and the „?:“ operator using both
22 methods.
23 Output may be something like that:
24
25 :php-benchmark/benchmarks$ php example.php
26 Benchmark by time...
27 +-------------+--------+------------+
28 | Name | Count | Percentage |
29 +-------------+--------+------------+
30 | ?: operator | 395106 | 100% |
31 | switch(){} | 427235 | 108% |
32 +-------------+--------+------------+
33 Benchmark by calls...
34 +-------------+---------------+------------+
35 | Name | Time | Percentage |
36 +-------------+---------------+------------+
37 | switch(){} | 2.60735988617 | 100% |
38 | ?: operator | 3.03899979591 | 117% |
39 +-------------+---------------+------------+
40
41 NOTE
42 ====
43 In the context of this class 'performance' is meaned referring to time.
44 The class does NOT detect CPU load, RAM usage or such things.
45
46 Can I help you?
47 ===============
48 Of course! I'm sure the files contain programming errors and lots of
49 English language mistakes. Find them and send them to me ;-)
50
51 COPYRIGHT AND LICENSE
52 =====================
53 Written by Raphael Michel <php-benchmark@raphaelmichel.de>
54 Copyright 2010 Raphael Michel
55
56 Released under the terms of the GNU General Public License
Something went wrong with that request. Please try again.