Skip to content

Commit

Permalink
added athletic performance test.
Browse files Browse the repository at this point in the history
Conflicts:
	composer.json
  • Loading branch information
staabm committed Nov 5, 2013
1 parent 2ed47bf commit 0695fc5
Show file tree
Hide file tree
Showing 7 changed files with 99 additions and 3 deletions.
4 changes: 3 additions & 1 deletion .gitignore
@@ -1,2 +1,4 @@
xhprof/includes/config.inc.php
*.custom.php
*.custom.php
composer.lock
/vendor/
15 changes: 15 additions & 0 deletions .travis.yml
@@ -0,0 +1,15 @@
language: php

php:
- 5.3
- 5.4
- 5.5

before_script:
- composer self-update
- composer update --prefer-source
- mysql -e 'create database xhprof;'
- mysql xhprof < ./setup/database.sql

script:
- php -n ./vendor/bin/athletic --path ./tests/performance/ --bootstrap ./tests/Bootstrap.php --formatter GroupedFormatter
7 changes: 5 additions & 2 deletions composer.json
Expand Up @@ -16,7 +16,10 @@
"classmap": ["xhprof/classes"]
},
"require": {
"php": ">=5.3",
"ext-xhprof": ">=0.9"
"php": ">=5.3"
},
"require-dev": {
"phpunit/phpunit": ">=3.7",
"athletic/athletic": "~0.1.6"
}
}
20 changes: 20 additions & 0 deletions phpunit.xml.dist
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>

<phpunit
bootstrap="./tests/Bootstrap.php"
backupGlobals="false"
backupStaticAttributes="false"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
syntaxCheck="false"
>
<testsuites>
<testsuite name="xhprof.io Test Suite">
<directory>./tests/</directory>
</testsuite>
</testsuites>
</phpunit>
22 changes: 22 additions & 0 deletions tests/Bootstrap.php
@@ -0,0 +1,22 @@
<?php

ini_set('error_reporting', E_ALL);

$files = array(__DIR__ . '/../vendor/autoload.php', __DIR__ . '/../../../autoload.php');

foreach ($files as $file) {
if (file_exists($file)) {
$loader = require $file;

break;
}
}

if (! isset($loader)) {
throw new RuntimeException('vendor/autoload.php could not be found. Did you run `php composer.phar install`?');
}

/* @var $loader \Composer\Autoload\ClassLoader */
$loader->add('DataPersistancePerfEvent', __DIR__ .'/performance/');

unset($files, $file, $loader);
33 changes: 33 additions & 0 deletions tests/performance/DataPersistancePerfEvent.php
@@ -0,0 +1,33 @@
<?php

class DataPersistancePerfEvent extends Athletic\AthleticEvent {
/**
* @var array
*/
private $testProfile;

/**
* @var PDO
*/
private $pdo;

public function classSetUp()
{
$this->testProfile = unserialize(file_get_contents(dirname(__FILE__) .'/test.profile'));
$this->pdo = new PDO('mysql:dbname=xhprof;host=127.0.0.1', 'root', '');
}

/**
* @iterations 1000
*/
public function persistProfile()
{
// XXX fake server env in a cleaner way
$_SERVER['HTTP_HOST'] = 'localhost';
$_SERVER['REQUEST_URI'] = '/index.htm';
$_SERVER['REQUEST_METHOD'] = 'GET';

$xhprof_data_obj = new \ay\xhprof\Data($this->pdo);
$xhprof_data_obj->save($this->testProfile);
}
}
1 change: 1 addition & 0 deletions tests/performance/test.profile

Large diffs are not rendered by default.

0 comments on commit 0695fc5

Please sign in to comment.