diff options
author | Taufan Aditya <toopay@taufanaditya.com> | 2012-05-15 13:47:24 +0200 |
---|---|---|
committer | Taufan Aditya <toopay@taufanaditya.com> | 2012-05-15 13:47:24 +0200 |
commit | 570e77cd78e0c704b032c3e7702372ca63d5ddaa (patch) | |
tree | 0a8a2db712234a421449af687294e625a4d61888 /tests | |
parent | 242925bc084e4d606d5f34bdb49bdf9f5235ec32 (diff) |
Benchmark code-coverage
Diffstat (limited to 'tests')
-rw-r--r-- | tests/codeigniter/core/Benchmark_test.php | 42 | ||||
-rw-r--r-- | tests/mocks/core/benchmark.php | 3 |
2 files changed, 45 insertions, 0 deletions
diff --git a/tests/codeigniter/core/Benchmark_test.php b/tests/codeigniter/core/Benchmark_test.php new file mode 100644 index 000000000..2790b582e --- /dev/null +++ b/tests/codeigniter/core/Benchmark_test.php @@ -0,0 +1,42 @@ +<?php + +class Benchmark_test extends CI_TestCase { + + public function set_up() + { + $this->benchmark = new Mock_Core_Benchmark(); + } + + // -------------------------------------------------------------------- + + public function test_mark() + { + $this->assertEmpty($this->benchmark->marker); + + $this->benchmark->mark('code_start'); + + $this->assertEquals(1, count($this->benchmark->marker)); + $this->assertArrayHasKey('code_start', $this->benchmark->marker); + } + + // -------------------------------------------------------------------- + + public function test_elapsed_time() + { + $this->assertEquals('{elapsed_time}', $this->benchmark->elapsed_time()); + $this->assertEmpty($this->benchmark->elapsed_time('undefined_point')); + + $this->benchmark->mark('code_start'); + sleep(1); + $this->benchmark->mark('code_end'); + + $this->assertEquals('1.00', $this->benchmark->elapsed_time('code_start', 'code_end', 3)); + } + + // -------------------------------------------------------------------- + + public function test_memory_usage() + { + $this->assertEquals('{memory_usage}', $this->benchmark->memory_usage()); + } +}
\ No newline at end of file diff --git a/tests/mocks/core/benchmark.php b/tests/mocks/core/benchmark.php new file mode 100644 index 000000000..d92be21db --- /dev/null +++ b/tests/mocks/core/benchmark.php @@ -0,0 +1,3 @@ +<?php + +class Mock_Core_Benchmark extends CI_Benchmark {}
\ No newline at end of file |