Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 72 additions & 0 deletions benchmarks/StoredAssetQueryBench.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
<?php

use asset\StoredAssetQuery;
use creator\Creator;
use misc\StringUtil;
use PhpBench\Attributes as Bench;

class StoredAssetQueryBench
{
private array $queryStrings;

public function __construct()
{
// Setup test data for benchmarks
$this->queryStrings = [
"wood",
"sand wet",
"chair",
"wood floor dark"
];
}

#[Bench\Revs(15)]
#[Bench\Iterations(3)]
#[Bench\Warmup(2)]
public function benchGetAllAssetsCreatorCount(): void
{
$query = new StoredAssetQuery();
$result = $query->executeCountByCreator();
assert(count($result) == count(Creator::cases()));
}

#[Bench\Revs(15)]
#[Bench\Iterations(3)]
#[Bench\Warmup(2)]
public function benchGetAllAssetsWithoutTags(): void
{
$query = new StoredAssetQuery();
$result = $query->execute(includeTags: false);
assert(count($result) >= 0);
}

#[Bench\Revs(15)]
#[Bench\Iterations(3)]
#[Bench\Warmup(2)]
public function benchGetLimitedAssetsWithoutTags(): void
{
$query = new StoredAssetQuery(limit: 150);
$result = $query->execute(includeTags: false);
assert(count($result) >= 0);
}

#[Bench\Revs(15)]
#[Bench\Iterations(3)]
#[Bench\Warmup(2)]
public function benchGetAllAssetsWithTags(): void
{
$query = new StoredAssetQuery();
$result = $query->execute(includeTags: true);
assert(count($result) >= 0);
}

#[Bench\Revs(15)]
#[Bench\Iterations(3)]
#[Bench\Warmup(2)]
public function benchGetLimitedAssetsWithTags(): void
{
$query = new StoredAssetQuery(limit: 150);
$result = $query->execute(includeTags: true);
assert(count($result) >= 0);
}
}
2 changes: 2 additions & 0 deletions cli/scrape-creator.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@

$creator->resetFailedAttempts($now);

Database::optimize();

Thumbnail::deleteOrphanedThumbnails();

Log::stop(true);
5 changes: 3 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@
},
"require-dev": {
"phpstan/phpstan": "^2.1",
"phpunit/phpunit": "13"
"phpunit/phpunit": "13",
"phpbench/phpbench": "^1.4"
},
"autoload": {
"psr-4": {
"\\": "include/"
}
}
}
}
Loading