Sfoglia il codice sorgente

adding tideways v5-beta2 image with php 7.2

vpoturaev 7 anni fa
parent
commit
36d39b85f9
5 ha cambiato i file con 85 aggiunte e 6 eliminazioni
  1. 3 3
      Dockerfile
  2. 26 0
      Dockerfile.v5
  3. 15 3
      Makefile
  4. 2 0
      README.md
  5. 39 0
      prepend_v5.php

+ 3 - 3
Dockerfile

@@ -1,6 +1,8 @@
 FROM php:7.2-cli
 
-RUN curl "https://github.com/tideways/php-profiler-extension/archive/v4.1.5.tar.gz" -fsL -o ./a.tar.gz  && \
+RUN apt-get update && apt-get install -y graphviz && apt-get clean
+
+RUN curl "https://github.com/tideways/php-xhprof-extension/archive/v4.1.5.tar.gz" -fsL -o ./a.tar.gz  && \
      tar xf ./a.tar.gz && \
      ls -la && cd ./php-xhprof-extension-4.1.5 && \
      ls -la && \
@@ -11,8 +13,6 @@ RUN curl "https://github.com/tideways/php-profiler-extension/archive/v4.1.5.tar.
      cd .. && rm -rf ./a.tar.gz ./php-xhprof-extension-4.1.5 && \
      docker-php-ext-enable tideways
 
-RUN apt-get update && apt-get install -y graphviz && apt-get clean
-
 COPY ./prepend_v4.php /prepend.php
 
 COPY ./php.ini /usr/local/etc/php/

+ 26 - 0
Dockerfile.v5

@@ -0,0 +1,26 @@
+FROM php:7.2-cli
+
+RUN apt-get update && apt-get install -y graphviz && apt-get clean
+
+RUN curl "https://github.com/tideways/php-xhprof-extension/archive/v5.0-beta2.tar.gz" -fsL -o ./a.tar.gz  && \
+     tar xf ./a.tar.gz && \
+     ls -la && cd ./php-xhprof-extension-5.0-beta2 && \
+     ls -la && \
+     phpize && \
+     ./configure && \
+     make && \
+     make install && \
+     cd .. && rm -rf ./a.tar.gz ./php-xhprof-extension-5.0-beta2 && \
+     docker-php-ext-enable tideways_xhprof
+
+COPY ./prepend_v5.php /prepend.php
+
+COPY ./php.ini /usr/local/etc/php/
+
+COPY ./xhprof/xhprof_lib/utils /utils
+
+ENV SVG=$SVG
+
+ENV REPORT=$REPORT
+
+WORKDIR /code

+ 15 - 3
Makefile

@@ -4,14 +4,26 @@ build:
 push:
 	docker push phperf/php-profiler:latest
 
+build-v4:
+	docker build -t phperf/php-profiler:7.2-tideways-v4 -f Dockerfile .
+
+push-v4:
+	docker push phperf/php-profiler:7.2-tideways-v4
+
+build-v5:
+	docker build -t phperf/php-profiler:7.2-tideways-v5 -f Dockerfile.v5 .
+
+push-v5:
+	docker push phperf/php-profiler:7.2-tideways-v5
+
 build-xhprof:
 	docker build -t phperf/php-profiler:5.6-xhprof -f Dockerfile.xhprof_php56 .
 
-build-uprofiler:
-	docker build -t phperf/php-profiler:5.6-uprofiler -f Dockerfile.uprofiler_php56 .
-
 push-xhprof:
 	docker push phperf/php-profiler:5.6-xhprof
 
+build-uprofiler:
+	docker build -t phperf/php-profiler:5.6-uprofiler -f Dockerfile.uprofiler_php56 .
+
 push-uprofiler:
 	docker push phperf/php-profiler:5.6-uprofiler

+ 2 - 0
README.md

@@ -70,5 +70,7 @@ Saving report to rep.json
 ## Tags
 
 * `phperf/php-profiler:latest` PHP 7.2, tideways 4.1.5, [Dockerfile](https://github.com/phperf/profiler-docker/blob/master/Dockerfile)
+* `phperf/php-profiler:7.2-tideways-v4` PHP 7.2, tideways 4.1.5, [Dockerfile](https://github.com/phperf/profiler-docker/blob/master/Dockerfile)
+* `phperf/php-profiler:7.2-tideways-v5` PHP 7.2, tideways 5.0-beta2, [Dockerfile](https://github.com/phperf/profiler-docker/blob/master/Dockerfile.v5)
 * `phperf/php-profiler:5.6-xhprof` PHP 5.6, xhprof 0.9.4, [Dockerfile](https://github.com/phperf/profiler-docker/blob/master/Dockerfile.xhprof_php56)
 * `phperf/php-profiler:5.6-uprofiler` PHP 5.6, uprofiler, [Dockerfile](https://github.com/phperf/profiler-docker/blob/master/Dockerfile.uprofiler_php56)

+ 39 - 0
prepend_v5.php

@@ -0,0 +1,39 @@
+<?php
+
+register_shutdown_function(
+    function () {
+        register_shutdown_function(function () {
+            $data = tideways_xhprof_disable();
+            echo 'Nodes in report: ' . count($data) . "\n";
+            $name = getenv('REPORT');
+            if (empty($name)) {
+                $name = 'xhprof_report.' . microtime(1) . '.serialized';
+            }
+            echo 'Saving report to ' . $name, "\n";
+
+            file_put_contents('/code/' . $name,
+                '.json' === substr($name, -5) ? json_encode($data) : serialize($data));
+
+            if (getenv('SVG')) {
+                include_once "/utils/callgraph_utils.php";
+                include_once "/utils/xhprof_lib.php";
+                include_once "/utils/xhprof_runs.php";
+
+                echo "Generating dot script\n";
+                $threshold = 0;
+                if (count($data) > 1000) {
+                    $threshold = 0.001;
+                }
+                $script = xhprof_generate_dot_script($data, $threshold, null, null, null, null);
+                echo "Generating dot image\n";
+                $content = xhprof_generate_image_by_dot($script, 'svg');
+                echo 'Saving graph to ' . $name . '.svg', "\n";
+                file_put_contents('/code/' . $name . '.svg',
+                    $content);
+            }
+        });
+    }
+);
+
+tideways_xhprof_enable(TIDEWAYS_XHPROF_FLAGS_MEMORY | TIDEWAYS_XHPROF_FLAGS_CPU);
+