Bläddra i källkod

CPU profiling test

Viacheslav Poturaev 6 år sedan
förälder
incheckning
dc7123056a
6 ändrade filer med 30 tillägg och 0 borttagningar
  1. 1 0
      prepend_uprofiler.php
  2. 1 0
      prepend_v4.php
  3. 1 0
      prepend_v5.php
  4. 1 0
      prepend_xhprof.php
  5. 15 0
      test/php_cpu.php
  6. 11 0
      test/run_cpu.sh

+ 1 - 0
prepend_uprofiler.php

@@ -3,6 +3,7 @@
 register_shutdown_function(
     function () {
         register_shutdown_function(function () {
+            echo "Uprofiler: ", phpversion("uprofiler"), ", PHP: ", phpversion(), "\n";
             $data = uprofiler_disable();
             echo 'Nodes in report: ' . count($data) . "\n";
             $name = getenv('REPORT');

+ 1 - 0
prepend_v4.php

@@ -4,6 +4,7 @@ register_shutdown_function(
     function () {
         register_shutdown_function(function () {
             $data = tideways_disable();
+            echo "Tideways: ", phpversion("tideways"), ", PHP: ", phpversion(), "\n";
             echo 'Nodes in report: ' . count($data) . "\n";
             $name = getenv('REPORT');
             if (empty($name)) {

+ 1 - 0
prepend_v5.php

@@ -4,6 +4,7 @@ register_shutdown_function(
     function () {
         register_shutdown_function(function () {
             $data = tideways_xhprof_disable();
+            echo "TidewaysXHPROF: ", phpversion("tideways_xhprof"), ", PHP: ", phpversion(), "\n";
             echo 'Nodes in report: ' . count($data) . "\n";
             $name = getenv('REPORT');
             if (empty($name)) {

+ 1 - 0
prepend_xhprof.php

@@ -4,6 +4,7 @@ register_shutdown_function(
     function () {
         register_shutdown_function(function () {
             $data = xhprof_disable();
+            echo "XHPROF: ", phpversion("xhprof"), ", PHP: ", phpversion(), "\n";
             echo 'Nodes in report: ' . count($data) . "\n";
             $name = getenv('REPORT');
             if (empty($name)) {

+ 15 - 0
test/php_cpu.php

@@ -0,0 +1,15 @@
+<?php
+
+function nestedCPU($limit)
+{
+    if ($limit === 0) {
+        return;
+    }
+    $n = 0;
+    for ($i = 0; $i < 100000; $i++) {
+        $n = $n ^ $i;
+    }
+    nestedCPU($limit - 1);
+}
+
+nestedCPU(5);

+ 11 - 0
test/run_cpu.sh

@@ -0,0 +1,11 @@
+#!/bin/bash
+
+docker run --rm -e REPORT=php_cpu_v4_72.json -v $(pwd):/code phperf/php-profiler:7.2-tideways-v4 php php_cpu.php
+docker run --rm -e REPORT=php_cpu_v5_72.json -v $(pwd):/code phperf/php-profiler:7.2-tideways-v5 php php_cpu.php
+
+docker run --rm -e REPORT=php_cpu_v4_73.json -v $(pwd):/code phperf/php-profiler:7.3-tideways-v4 php php_cpu.php
+docker run --rm -e REPORT=php_cpu_v5_73.json -v $(pwd):/code phperf/php-profiler:7.3-tideways-v5 php php_cpu.php
+
+docker run --rm -e REPORT=php_cpu_xhprof_56.json -v $(pwd):/code phperf/php-profiler:xhprof php php_cpu.php
+docker run --rm -e REPORT=php_cpu_uprofiler_56.json -v $(pwd):/code phperf/php-profiler:uprofiler php php_cpu.php
+