PHP code example of phpbenchmarks / benchmark-json-serialization-big-overload

1. Go to this page and download the library: Download phpbenchmarks/benchmark-json-serialization-big-overload library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

phpbenchmarks / benchmark-json-serialization-big-overload example snippets


use PhpBenchmarks\BenchmarkJsonSerializationBigOverload\BenchmarkService;

BenchmarkService::getDataToSerialize();

use PhpBenchmarks\BenchmarkJsonSerializationBigOverload\BenchmarkService;

// Write serialized data to response body if isWriteToResponseBody() return true, to validate it.
if (BenchmarkService::isWriteToResponseBody()) {
    echo $serializer->serialize(BenchmarkService::getDataToSerialize());

// Only serialize data if isWriteToResponseBody() return false, to benchmark it.
} else {
    $serializer->serialize(BenchmarkService::getDataToSerialize());
}