Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add source list view and UI for selecting runs to compare. #21

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
extension/*
!extension/config.m4
!extension/Makefile.local
!extension/php_xhprof.h
!extension/tests/
!extension/xhprof.c
23 changes: 23 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
language: php

notifications:
email: false

php:
- 5.5
- 5.4
- 5.3
- 5.3.3

env:
global:
- TEST_PHP_ARGS="-q"
- REPORT_EXIT_STATUS=1

before_script:
- cd extension
- phpize
- ./configure
- make -j4

script: make -f Makefile.local test_with_exit_status
35 changes: 35 additions & 0 deletions extension/Makefile.local
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
include Makefile

GOODPHP = $(shell $(PHP_EXECUTABLE) -r 'echo version_compare(phpversion(), "5.5.0", ">=");')
ifeq ($(GOODPHP), 1)
TESTTARGET = test
else
TESTTARGET = test_from_php55
endif

test_with_exit_status: $(TESTTARGET)

# Fixed test target from PHP 5.5.
test_from_php55:
@if test ! -z "$(PHP_EXECUTABLE)" && test -x "$(PHP_EXECUTABLE)"; then \
INI_FILE=`$(PHP_EXECUTABLE) -d 'display_errors=stderr' -r 'echo php_ini_loaded_file();' 2> /dev/null`; \
if test "$$INI_FILE"; then \
$(EGREP) -h -v $(PHP_DEPRECATED_DIRECTIVES_REGEX) "$$INI_FILE" > $(top_builddir)/tmp-php.ini; \
else \
echo > $(top_builddir)/tmp-php.ini; \
fi; \
INI_SCANNED_PATH=`$(PHP_EXECUTABLE) -d 'display_errors=stderr' -r '$$a = explode(",\n", trim(php_ini_scanned_files())); echo $$a[0];' 2> /dev/null`; \
if test "$$INI_SCANNED_PATH"; then \
INI_SCANNED_PATH=`$(top_srcdir)/build/shtool path -d $$INI_SCANNED_PATH`; \
$(EGREP) -h -v $(PHP_DEPRECATED_DIRECTIVES_REGEX) "$$INI_SCANNED_PATH"/*.ini >> $(top_builddir)/tmp-php.ini; \
fi; \
TEST_PHP_EXECUTABLE=$(PHP_EXECUTABLE) \
TEST_PHP_SRCDIR=$(top_srcdir) \
CC="$(CC)" \
$(PHP_EXECUTABLE) -n -c $(top_builddir)/tmp-php.ini $(PHP_TEST_SETTINGS) $(top_srcdir)/run-tests.php -n -c $(top_builddir)/tmp-php.ini -d extension_dir=$(top_builddir)/modules/ $(PHP_TEST_SHARED_EXTENSIONS) $(TESTS); \
TEST_RESULT_EXIT_CODE=$$?; \
rm $(top_builddir)/tmp-php.ini; \
exit $$TEST_RESULT_EXIT_CODE; \
else \
echo "ERROR: Cannot run tests without CLI sapi."; \
fi
8 changes: 4 additions & 4 deletions extension/xhprof.c
Original file line number Diff line number Diff line change
Expand Up @@ -820,7 +820,7 @@ int hp_ignore_entry_work(uint8 hash_code, char *curr_func) {
return ignore;
}

inline int hp_ignore_entry(uint8 hash_code, char *curr_func) {
static inline int hp_ignore_entry(uint8 hash_code, char *curr_func) {
/* First check if ignoring functions is enabled */
return hp_globals.ignored_function_names != NULL &&
hp_ignore_entry_work(hash_code, curr_func);
Expand Down Expand Up @@ -1218,7 +1218,7 @@ void hp_sample_check(hp_entry_t **entries TSRMLS_DC) {
* @return 64 bit unsigned integer
* @author cjiang
*/
inline uint64 cycle_timer() {
static inline uint64 cycle_timer() {
uint32 __a,__d;
uint64 val;
asm volatile("rdtsc" : "=a" (__a), "=d" (__d));
Expand Down Expand Up @@ -1280,7 +1280,7 @@ static void incr_us_interval(struct timeval *start, uint64 incr) {
*
* @author cjiang
*/
inline double get_us_from_tsc(uint64 count, double cpu_frequency) {
static inline double get_us_from_tsc(uint64 count, double cpu_frequency) {
return count / cpu_frequency;
}

Expand All @@ -1293,7 +1293,7 @@ inline double get_us_from_tsc(uint64 count, double cpu_frequency) {
*
* @author veeve
*/
inline uint64 get_tsc_from_us(uint64 usecs, double cpu_frequency) {
static inline uint64 get_tsc_from_us(uint64 usecs, double cpu_frequency) {
return (uint64) (usecs * cpu_frequency);
}

Expand Down
100 changes: 86 additions & 14 deletions xhprof_lib/utils/xhprof_runs.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,20 +146,92 @@ public function save_run($xhprof_data, $type, $run_id = null) {
return $run_id;
}

function list_runs() {
if (is_dir($this->dir)) {
echo "<hr/>Existing runs:\n<ul>\n";
$files = glob("{$this->dir}/*.{$this->suffix}");
usort($files, create_function('$a,$b', 'return filemtime($b) - filemtime($a);'));
foreach ($files as $file) {
list($run,$source) = explode('.', basename($file));
echo '<li><a href="' . htmlentities($_SERVER['SCRIPT_NAME'])
. '?run=' . htmlentities($run) . '&source='
. htmlentities($source) . '">'
. htmlentities(basename($file)) . "</a><small> "
. date("Y-m-d H:i:s", filemtime($file)) . "</small></li>\n";
}
echo "</ul>\n";
public function get_run_files() {
$files = glob("{$this->dir}/*.{$this->suffix}");
usort($files, function($a,$b) {
return filemtime($b) - filemtime($a);
});
return $files;
}

public function get_run_list() {
$files = $this->get_run_files();
$list = array();
foreach ($files as $file) {
list($run,$source) = explode('.', basename($file));
$list[] = array( 'run' => $run , 'source' => $source , 'file' => $file );
}
return $list;
}


public function get_run_files_by_source() {
$files = $this->get_run_files();
$sources = array();
foreach( $files as $file ) {
list($run,$source) = explode('.', basename($file));
$sources[$source][] = array( 'run' => $run , 'file' => $file, 'source' => $source );
}
return $sources;
}

public function list_sources() {
$sources = $this->get_run_files_by_source();
echo '<h3>Sources</h3>';
echo '<ul>';
foreach ($sources as $source => $runs) {
echo '<li><a href="?source='. $source .'">'.$source.'</a></li>';
}
echo '</ul>';
}

public function list_runs() {
if ( ! is_dir($this->dir) ) {
return;
}

if ( ! isset($_GET['source']) ) {
$this->list_sources();
return;
}

echo '<form method="GET">';

echo 'Source: <input type="text" name="source" value="'. $_GET['source'] .'"/>';

echo "<hr/>Existing runs:\n";

echo '<input type="submit" name="compare" value="Compare"/>';

echo "<table>\n";
echo '<tr>';
echo '<th>Run1</th>';
echo '<th>Run2</th>';
echo '<th>Source File</th>';
echo '<th>Time</th>';
echo '</tr>';

$files = $this->get_run_files();
foreach ($files as $file) {
list($run,$source) = explode('.', basename($file));

if ( $source !== $_GET['source'] ) {
continue;
}
$htmlized_run = htmlentities($run);

echo '<tr>';
echo '<td align="center"><input type="radio" name="run1" value="' . $htmlized_run . '"/></td>';
echo '<td align="center"><input type="radio" name="run2" value="' . $htmlized_run . '"/></td>';
echo '<td><a href="' . htmlentities($_SERVER['SCRIPT_NAME'])
. '?run=' . $htmlized_run . '&source='
. htmlentities($source) . '">'
. htmlentities(basename($file)) . "</a>"
. "</td>\n";
echo '<td><small><time>' . date("Y-m-d H:i:s", filemtime($file)) . '</time></small></td>';
echo '</tr>';
}
echo "</table>\n";
echo '</form>';
}
}