<?php /* * This file is part of the kompakt/b3d package. * * (c) Christian Hoegl <*****@*****.**> * */ require sprintf('%s/bootstrap.php', dirname(__DIR__)); use GuzzleHttp\Client; use Kompakt\B3d\Details\Endpoint\Resource\Stock\Endpoint as StockEndpoint; use Kompakt\B3d\Details\Endpoint\Cache\PhpFile\Serializer as PhpFileSerializer; use Kompakt\B3d\Util\File\Writer; use Symfony\Component\Stopwatch\Stopwatch; $tmpDir = getTmpDir(); $phpSerializerTmpDirPathname = $tmpDir->replaceSubDir('php-cache-stock-data'); // http client $client = new Client(); // data file $stockFilePathname = sprintf('%s/stocks.data', $phpSerializerTmpDirPathname); // endpoint $stockEndpoint = new StockEndpoint($client, EXAMPLE_KOMPAKT_B3D_BASE_URL, EXAMPLE_KOMPAKT_B3D_API_KEY); // serializer $stockPhpFileSerializer = new PhpFileSerializer(new Writer(), $stockFilePathname); // run $stopwatch = new Stopwatch(); $stopwatch->start('b3d', 'b3d'); $stockPhpFileSerializer->serialize($stockEndpoint->fetch(['uuid-1', 'uuid-2'])); $event = $stopwatch->stop('b3d'); echo sprintf("%s\n", $event);
$trackFilePathname = sprintf('%s/tracks.data', $phpSerializerTmpDirPathname); // http client $client = new Client(); // endpoints $artistEndpoint = new ArtistEndpoint($client, EXAMPLE_KOMPAKT_B3D_BASE_URL, EXAMPLE_KOMPAKT_B3D_API_KEY); $labelEndpoint = new LabelEndpoint($client, EXAMPLE_KOMPAKT_B3D_BASE_URL, EXAMPLE_KOMPAKT_B3D_API_KEY); $priceEndpoint = new PriceEndpoint($client, EXAMPLE_KOMPAKT_B3D_BASE_URL, EXAMPLE_KOMPAKT_B3D_API_KEY); $productEndpoint = new ProductEndpoint($client, EXAMPLE_KOMPAKT_B3D_BASE_URL, EXAMPLE_KOMPAKT_B3D_API_KEY); $productTrackEndpoint = new ProductTrackEndpoint($client, EXAMPLE_KOMPAKT_B3D_BASE_URL, EXAMPLE_KOMPAKT_B3D_API_KEY); $releaseEndpoint = new ReleaseEndpoint($client, EXAMPLE_KOMPAKT_B3D_BASE_URL, EXAMPLE_KOMPAKT_B3D_API_KEY); $trackEndpoint = new TrackEndpoint($client, EXAMPLE_KOMPAKT_B3D_BASE_URL, EXAMPLE_KOMPAKT_B3D_API_KEY); // serializers $artistPhpFileSerializer = new PhpFileSerializer(new Writer(), $artistFilePathname); $labelPhpFileSerializer = new PhpFileSerializer(new Writer(), $labelFilePathname); $pricePhpFileSerializer = new PhpFileSerializer(new Writer(), $priceFilePathname); $productPhpFileSerializer = new PhpFileSerializer(new Writer(), $productFilePathname); $productTrackPhpFileSerializer = new PhpFileSerializer(new Writer(), $productTrackFilePathname); $releasePhpFileSerializer = new PhpFileSerializer(new Writer(), $releaseFilePathname); $trackPhpFileSerializer = new PhpFileSerializer(new Writer(), $trackFilePathname); // run $stopwatch = new Stopwatch(); $stopwatch->start('b3d', 'b3d'); $artistPhpFileSerializer->serialize($artistEndpoint->fetchAll()); $labelPhpFileSerializer->serialize($labelEndpoint->fetchAll()); $pricePhpFileSerializer->serialize($priceEndpoint->fetchAll()); $productPhpFileSerializer->serialize($productEndpoint->fetchAll()); $productTrackPhpFileSerializer->serialize($productTrackEndpoint->fetchAll()); $releasePhpFileSerializer->serialize($releaseEndpoint->fetchAll()); $trackPhpFileSerializer->serialize($trackEndpoint->fetchAll()); $event = $stopwatch->stop('b3d'); echo sprintf("%s\n", $event);