Skip to content

Instantly share code, notes, and snippets.

#include <stdio.h>
#include <stdlib.h>
#include <sys/time.h>
#include <sys/resource.h>
double get_time()
{
struct timeval t;
struct timezone tzp;
gettimeofday(&t, &tzp);
@ircmaxell
ircmaxell / bench.md
Created October 1, 2014 19:53
Benchmarks

The following table is the result of running this benchmark.

Columns headed by -O followed by a number are PECL extensions generated by Recki using the experimental PECL compiler backend (on github). Each is the result of compiling the extension with the optimization level indicated.

                 | PHP 5.6.1-dev | ReckiCT -O0 | ReckiCT -O1 | ReckiCT -O2 | ReckiCT -O3 | ReckiCT Jit| HHVM - 3.1.0 

---------------------|---------------|-------------|-------------|-------------|-------------|------------|-------------- simple() | 12748.56186 | 366.82990 | 79.26289 | 25.29381 | 1.00000 | 137.26289 | 272.77835

@ircmaxell
ircmaxell / data.md
Created August 30, 2014 03:16
Environment

Tested configurations

Operating system:

  • Ubuntu

  • CentOS 6.5

    I did have some weird autoconf issues, so I had to build a newer version of autoconf from scratch. This is not necessary on Ubuntu

LIBJIT:

@ircmaxell
ircmaxell / bench.php
Last active January 3, 2018 22:33
bench.php
<?php
use ReckiCT\Jit;
if (function_exists('class_alias')) {
// HippyVM doesn't have a class_alias, so this will break things.
require __DIR__ . '/../vendor/autoload.php';
}
define("IM", 139968);
<?php
/**
* @covers ::generateText
*/
public function testGenerateText() {
$a = p::mock(Vertex::class);
p::when($a)->__toString()->thenReturn('a');
$b = p::mock(Vertex::class);
p::when($b)->__toString()->thenReturn('b');
<?php
namespace Gliph\Graph;
/**
* Interface for bidirectional directed graph datastructures.
*/
interface BiDirectedGraph extends DirectedGraph {
/**
@ircmaxell
ircmaxell / raw.php
Created July 29, 2014 18:31
Dump Gliph to GraphViz
<?php
public function dump(DirectedAdjacencyList $func, $filename) {
$ctr = 0;
$graph = Graph::create("dump");
$nodes = new \SplObjectStorage;
$scope = new \SplObjectStorage;
foreach ($func->eachVertex() as $vertex => $_) {
$nodes[$vertex] = Node::create('node_' . $ctr++);
$graph->setNode($nodes[$vertex]);
<?php
/**
* @param int
* @param int
* @return int
*/
function foo($a, $b) {
$c = 0;
if ($a) {
@ircmaxell
ircmaxell / gist:6fa2ea9417056be7aba7
Created July 25, 2014 21:35
Dump of #php.pecl convo
13:11 <ajf> I’m mostly happy with it as-is, but given that I made int/float/numeric/string not accept NULL, I think booleans shouldn’t be accepted for them either.
13:19 → arty joined ⇐ DaveRand quit
13:49 → sonotos and lonnylot joined ⇐ dmitry and RemiFedor quit
14:41 <ircmaxell> ajf: that sounds sane (consistency wise). So it means that `int/float/numeric` only accept int/float/valid-number-string, and string only accepts string/int/float
14:43 <ajf> ircmaxell: Yeah
14:43 <ajf> Also, we don’t accept int/float/string for bool, so we shouldn’t accept bool for int/float/string
14:43 <ircmaxell> yeah, makes perfect sense
14:44 <ajf> Another point someone raised was that FALSE is a common error value alongside NULL.
14:44 <ajf> So, should I go ahead and amend the patch and RFC to do that?
14:44 <ircmaxell> I think that's the direction we're going, so that's valid
<?php
define('CRYPT_SALT_LEN_MAX', 16);
define('CRYPT_ROUNDS_DEFAULT', 5000);
/**
* A PHP shim for crypt sha256 and sha512
* to workaround bug 62372
* @see https://bugs.php.net/bug.php?id=62372
*/