Skip to content

Commit 6354034

Browse files
committed
Small JSON serialization for PHP 5.6.35
0 parents  commit 6354034

File tree

11 files changed

+256
-0
lines changed

11 files changed

+256
-0
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/vendor/
2+
/composer.lock
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
<?php
2+
3+
namespace AbstractComponentConfiguration;
4+
5+
abstract class AbstractComponentConfiguration
6+
{
7+
public static function getComponentType()
8+
{
9+
return 1;
10+
}
11+
12+
public static function getComponentName()
13+
{
14+
return 'PHP';
15+
}
16+
17+
public static function getComponentSlug()
18+
{
19+
return 'php';
20+
}
21+
22+
public static function isPhp56Enabled()
23+
{
24+
return true;
25+
}
26+
27+
public static function isPhp70Enabled()
28+
{
29+
return false;
30+
}
31+
32+
public static function isPhp71Enabled()
33+
{
34+
return false;
35+
}
36+
37+
public static function isPhp72Enabled()
38+
{
39+
return false;
40+
}
41+
42+
public static function isPhp73Enabled()
43+
{
44+
return false;
45+
}
46+
47+
public static function getBenchmarkUrl()
48+
{
49+
return 'index.php';
50+
}
51+
52+
public static function getCoreDependencyName()
53+
{
54+
return 'php';
55+
}
56+
57+
public static function getCoreDependencyMajorVersion()
58+
{
59+
return 5;
60+
}
61+
62+
public static function getCoreDependencyMinorVersion()
63+
{
64+
return 6;
65+
}
66+
67+
public static function getCoreDependencyPatchVersion()
68+
{
69+
return 35;
70+
}
71+
72+
public static function getBenchmarkType()
73+
{
74+
return 7;
75+
}
76+
77+
public static function getSourceCodeUrls()
78+
{
79+
return [];
80+
}
81+
}

.phpbenchmarks/composer.lock.php5.6

Lines changed: 51 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.phpbenchmarks/initBenchmark.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/usr/bin/env bash
2+
3+
set -e
4+
5+
composer install --no-dev --classmap-authoritative --ansi

.phpbenchmarks/responseBody/responseBody.json

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.

.phpbenchmarks/vhost.conf

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
server {
2+
listen 80;
3+
server_name ____HOST____;
4+
root ____INSTALLATION_PATH____/public;
5+
location / {
6+
try_files $uri /index.php$is_args$args;
7+
}
8+
location ~ ^/(index).php(/|$) {
9+
fastcgi_pass unix:/run/php/____PHP_FPM_SOCK____;
10+
fastcgi_split_path_info ^(.+.php)(/.*)$;
11+
include fastcgi_params;
12+
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
13+
fastcgi_param HTTPS off;
14+
}
15+
error_log /var/log/nginx/benchmark_error.log;
16+
access_log /var/log/nginx/benchmark_access.log;
17+
}

README.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<p align="center">
2+
<img src="http://www.phpbenchmarks.com/images/logo_github.png">
3+
<br>
4+
<a href="http://www.phpbenchmarks.com" target="_blank">www.phpbenchmarks.com</a>
5+
</p>
6+
7+
## What is www.phpbenchmarks.com ?
8+
9+
You will find lot of benchmarks for PHP frameworks and template engines.
10+
11+
You can compare results between Apache Bench and Siege, and PHP 5.6 to 7.3.
12+
13+
## What is this repository ?
14+
15+
It's benchmark common code for PHP benchmarks.
16+
17+
Switch branch to select your PHP major version and benchmark you want to see.
18+
19+
See all PHP benchmarked versions on [phpbenchmarks/php](https://github.com/phpbenchmarks/php).
20+
21+
You can find how we benchmark on [benchmarking protocol page](http://www.phpbenchmarks.com/en/documentation/benchmarking-protocol).
22+
23+
## Benchmarks
24+
25+
You can find all PHP benchmarks results on [phpbenchmarks.com](http://www.phpbenchmarks.com/en/benchmark/php/version).
26+
27+
Scores are too low ? Do not hesitate to create a pull request, and ask a new benchmark !

composer.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"name": "phpbenchmarks/php",
3+
"license": "proprietary",
4+
"type": "project",
5+
"require": {
6+
"php": "5.6.*",
7+
"ext-json": "*",
8+
"phpbenchmarks/benchmark-json-serialization-small-overload": "1.0.0"
9+
},
10+
"autoload": {
11+
"psr-4": {
12+
"Php73\\BenchmarkJsonSerializationSmallOverload\\": "src/"
13+
}
14+
}
15+
}

public/index.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
3+
use Php73\BenchmarkJsonSerializationSmallOverload\ObjectToSerializeFactory\JsonSerializableFactory;
4+
use PhpBenchmarks\BenchmarkJsonSerializationSmallOverload\BenchmarkService;
5+
6+
require __DIR__ . '/../vendor/autoload.php';
7+
8+
$benchmarkService = new BenchmarkService(new JsonSerializableFactory());
9+
10+
if ($benchmarkService->isWriteToResponseBody()) {
11+
echo json_encode($benchmarkService->getDataToSerialize());
12+
} else {
13+
json_encode($benchmarkService->getDataToSerialize());
14+
}
15+
16+
// require phpbenchmarks stats.php here when needed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?php
2+
3+
namespace Php73\BenchmarkJsonSerializationSmallOverload\ObjectToSerialize;
4+
5+
use PhpBenchmarks\BenchmarkJsonSerializationSmallOverload\ObjectToSerialize\ObjectToSerialize;
6+
7+
class JsonSerializableToSerialize extends ObjectToSerialize implements \JsonSerializable
8+
{
9+
/** @return array */
10+
public function jsonSerialize()
11+
{
12+
return [
13+
'property1' => $this->getProperty1(),
14+
'property2' => $this->getProperty2(),
15+
'property3' => $this->getProperty3(),
16+
'property4' => $this->getProperty4(),
17+
'property5' => $this->getProperty5(),
18+
'property6' => $this->getProperty6(),
19+
'property7' => $this->getProperty7(),
20+
'property8' => $this->getProperty8(),
21+
'property9' => $this->getProperty9(),
22+
'property10' => $this->getProperty10()
23+
];
24+
}
25+
}

0 commit comments

Comments
 (0)