View prefetched.py
def prefetched_related(instance, name, default=None): | |
""" | |
Attempts to find and return prefetched data on a model. | |
Usage: | |
values, prefetched = prefetched_related(instance, 'name') | |
values : A list of prefetched values for the field. | |
prefetched : True if the requested field was prefetched on the instance. | |
""" |
View php_bug63217_benchmark.php
<?php | |
// See https://github.com/php/php-src/pull/3351 | |
$arr = [ | |
"foo" => true, | |
"foobar" => 3, | |
"elePHPant" => "qux", | |
"long_key_name" => "something contrived", | |
"123" => 76, |
View gmpi_dec_bench.php
<?php | |
ini_set('memory_limit', -1); | |
srand(0); | |
$length = 100000; | |
$maxInt = 10 ** 10; | |
$values = []; | |
for ($i = 0; $i < $length; $i++) { | |
$int = (rand() % $maxInt); |
View benchmark.php
<?php | |
use Decimal\Decimal; | |
/* Number of times to perform each calculation. */ | |
$iterations = 1000000; | |
/* Candidates */ | |
define("DECIMAL", "decimal"); | |
define("BC_MATH", "bcmath"); |
View copy_on_write_lazy_map.php
<?php | |
interface Collection | |
{ | |
/** | |
* @return static | |
*/ | |
function map(callable cb): Collection; | |
// filter | |
// reduce |
View decimal_refcount.php
<?php | |
$a = "1"; | |
$b = "2"; | |
/** | |
* This should reuse the decimal created for A as the result. | |
*/ | |
$c = \Decimal\Decimal::valueOf($a)->add($b); | |
debug_zval_dump($c); | |
// object(Decimal\Decimal)#1 (2) refcount(2){ |
View gist:64a362307d90b9c8405350024ef11a2a
#pragma once | |
#pragma warning(push) | |
#pragma warning(disable:4996) | |
#include <cassert> | |
#include <memory> | |
#include <vector> | |