Skip to content
The Symfony's Stopwatch Component in C
Branch: master
Clone or download
Pull request Compare This branch is 14 commits ahead of brikou:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
symfony/symfony/component/stopwatch
.gitignore
README.md
composer.json
dockerfile
makefile

README.md

Zephir Symfony Stopwatch

Edit

Made a few changes to the files

  1. Removed comments (causing errors)
  2. Removed $
  3. 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 build

edit 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 compile

Example

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());

EOF

Testing

make test
You can’t perform that action at this time.