cebe / php-openapi

Read and write OpenAPI yaml/json files and make the content accessible in PHP objects.
MIT License
469 stars 89 forks source link

Introduce a simple cache and build a new ReferenceContext only when needed #158

Open marcelthole opened 2 years ago

marcelthole commented 2 years ago

hey, maybe this could work and improve the perfomance for the use case in #156.

Here is a simple repo script:

<?php

require 'vendor/autoload.php';

$start = hrtime(true);
$openapi = \cebe\openapi\Reader::readFromYamlFile(__DIR__ . '/index.yaml');
$end = hrtime(true);

var_dump(number_format(($end - $start) / 1e6,4, ',', ' ') . ' ms');

and this are the before and after results (left after the change, right before) grafik