Zephir Symfony Stopwatch
Edit
Made a few changes to the files
- Removed comments (causing errors)
- Removed $
- Changed namespace
start a zephir init
$ zephir init symftest
$ cd symftest
$ mkdir stopwatch
to build project put project in the following folder
ext/
symftest/
stopwatch/
section.zep
stopwatch.zep
stowatchevent.zep
stopwatchperiod.zep
then proceed to build
$ zephir buildedit php.ini and add
extension=symftest.so
and lastly test.php
<?php
$stopwatch = new Symftest\Stopwatch\Stopwatch();
$stopwatch->start('EventA');
usleep(200000);
$eventA = $stopwatch->stop('EventA');
var_dump($eventA->getDuration());
//outputs float(201)The Symfony's Stopwatch Component delivered as a C extension with the gracefull help of Zephir.
Install
sudo docker build - < dockerfile
k=`sudo docker images -q | head -n1`
sudo docker run -v=$PWD:/root -i -t $k /bin/bash
cd /root/
make compileExample
php << 'EOF'
<?php
use Symfony\Component\Stopwatch\Stopwatch;
use Symfony\Component\Stopwatch\StopwatchEvent;
use Symfony\Component\Stopwatch\StopwatchPeriod;
$stopwatch = new Stopwatch();
$stopwatch->start('eventA');
usleep(200000);
$stopwatch->start('eventB');
usleep(200000);
$eventA = $stopwatch->stop('eventA');
$eventB = $stopwatch->stop('eventB');
printf("Duration of event A: %u ms.\n", $eventA->getDuration());
printf("Duration of event B: %u ms.\n", $eventB->getDuration());
EOFTesting
make test