Exemplo n.º 1
0
 function testBasicState()
 {
     Benchmark::__reset();
     $this->assertEqual(Benchmark::get_opened_benchmarks_count(), 0, "Benchmark gia' aperti");
     $b = Benchmark::start(__CLASS__, __METHOD__);
     $this->assertEqual(Benchmark::get_opened_benchmarks_count(), 1, "Nessun benchmark aperto");
     $this->assertTrue(Benchmark::stop() >= 0, "Il tempo del benchmark e' inferiore a 0");
     $this->assertEqual(Benchmark::get_opened_benchmarks_count(), 0, "Benchmark ancora aperto.");
     $r = Benchmark::start(__CLASS__, __METHOD__);
     $this->assertEqual(Benchmark::get_opened_benchmarks_count(), 1, "Benchmark aperti non 1.");
     $this->assertEqual($r->get_nested_benchmarks_count(), 0, "Numero di benchmark annidati non 0");
     Benchmark::start(__CLASS__, __METHOD__);
     Benchmark::stop();
     $this->assertEqual(Benchmark::get_opened_benchmarks_count(), 1, "Benchmark aperti non 1.");
     $this->assertEqual($r->get_nested_benchmarks_count(), 1, "Numero di benchmark annidati non 1");
     Benchmark::start(__CLASS__, __METHOD__);
     Benchmark::stop();
     $this->assertEqual(Benchmark::get_opened_benchmarks_count(), 1, "Benchmark aperti non 1.");
     $this->assertEqual($r->get_nested_benchmarks_count(), 2, "Numero di benchmark annidati non 2");
     Benchmark::start(__CLASS__, __METHOD__);
     $this->assertEqual(Benchmark::get_opened_benchmarks_count(), 2, "Benchmark aperti non 2.");
     Benchmark::stop();
     $this->assertEqual(Benchmark::get_opened_benchmarks_count(), 1, "Benchmark aperti non 1.");
     $this->assertEqual($r->get_nested_benchmarks_count(), 3, "Numero di benchmark annidati non 3");
     Benchmark::stop();
 }