Skip to content
Merged
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
Empty file added .env.example
Empty file.
14 changes: 14 additions & 0 deletions app/Actions/Specs/LaravelSpecs.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

namespace App\Actions\Specs;

use Illuminate\Support\Facades\Artisan;

class LaravelSpecs
{
public function execute()
{
Artisan::call('about --json');
return Artisan::output();
}
}
30 changes: 30 additions & 0 deletions app/Actions/Specs/PhpSpecs.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

namespace App\Actions\Specs;

class PhpSpecs
{
public function execute()
{
return [
'php_server_api' => $this->getPhpServerApi(),
'memory_limit' => $this->getMemoryLimit(),
'op_cache' => $this->getOpCache(),
];
}

public function getPhpServerApi()
{
return php_sapi_name();
}

public function getMemoryLimit()
{
return ini_get('memory_limit');
}

public function getOpCache()
{
return ini_get('opcache.enable');
}
}
67 changes: 67 additions & 0 deletions app/Actions/Specs/ServerSpecs.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
<?php

namespace App\Actions\Specs;

class ServerSpecs
{
public function execute()
{
return [
'cpu_model' => $this->getCpuModel(),
'cpu_cores' => $this->getCpuCores(),
'cpu_frequency' => $this->getCpuFrequency(),
'os' => $this->getOs(),
'ram' => $this->getRam(),
];
}

public function getCpuModel()
{
// Run multi-line command and capture output
$command = <<<'CMD'
if cpu_info=$(grep -m1 "model name" /proc/cpuinfo 2>/dev/null); then
echo "$cpu_info" | cut -d':' -f2- | sed 's/^ *//'
elif [[ "$OSTYPE" == "darwin"* ]]; then
sysctl -n machdep.cpu.brand_string 2>/dev/null
else
echo "Unknown Processor Model"
fi
CMD;

return trim(shell_exec($command));
}

public function getCpuCores()
{
$command = <<<'CMD'
[ -f /proc/cpuinfo ] && grep -c "^processor" /proc/cpuinfo || sysctl -n hw.ncpu 2>/dev/null
CMD;

return trim(shell_exec($command));
}

public function getCpuFrequency()
{
$command = <<<'CMD'
if cpu_info=$(grep -m1 "cpu MHz" /proc/cpuinfo 2>/dev/null); then
echo "$cpu_info" | cut -d':' -f2- | sed 's/^ *//'
else
echo "Unknown CPU Frequency"
fi
CMD;

return trim(shell_exec($command));
}

public function getOs()
{
return trim(shell_exec('grep "^PRETTY_NAME=" /etc/os-release | cut -d\'"\' -f2'));
}

public function getRam()
{
$ram = (int) trim(shell_exec('awk \'/MemTotal/ {print $2}\' /proc/meminfo'));
return round($ram / 1024, 3) . ' MB';
}

}
17 changes: 0 additions & 17 deletions app/Http/Controllers/AppController.php

This file was deleted.

28 changes: 28 additions & 0 deletions app/Http/Controllers/BenchmarkController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

namespace App\Http\Controllers;

use App\Http\Controllers\Controller;

use App\Actions\Specs\ServerSpecs;
use App\Actions\Specs\PhpSpecs;
use App\Actions\Specs\LaravelSpecs;
use Illuminate\Http\Request;
use Inertia\Inertia;

class BenchmarkController extends Controller
{
public function index( Request $request )
{
return Inertia::render('Index', [
'server' => Inertia::defer(fn () => ( new ServerSpecs() )->execute()),
'php' => Inertia::defer(fn () => ( new PhpSpecs() )->execute()),
'laravel' => Inertia::defer(fn () => ( new LaravelSpecs() )->execute()),
]);
}

public function store( Request $request )
{

}
}
64 changes: 64 additions & 0 deletions app/Http/Controllers/EventController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Symfony\Component\Process\Process;

class EventController extends Controller
{
public function index()
{
return response()->stream(function () {
while (ob_get_level()) {
ob_end_flush();
}
@ini_set('output_buffering', 'off');
@ini_set('zlib.output_compression', '0');
set_time_limit(0);

$bin = base_path('vendor/bin/yabs');
$results = base_path('yabs-results.json');

$command = sprintf(
'script -q /dev/null -c %s',
escapeshellarg(sprintf('%s -i -6 -w %s', $bin, $results))
);

$process = Process::fromShellCommandline($command, base_path(), null, null, null);


echo "retry: 2000\n\n"; // keep connection healthy
@ob_flush(); flush();

$process->run(function ($type, $buffer) {
$buffer = trim($buffer);
if ($buffer !== '') {
echo "data: " . json_encode([
'timestamp' => date('Y-m-d H:i:s'),
'type' => $type, // 'out' or 'err'
'output' => $buffer,
]) . "\n\n";
@ob_flush(); flush();
}
});

$status = $process->isSuccessful() ? 'completed' : 'error';
$error = $process->isSuccessful() ? null : $process->getExitCodeText();

echo "data: " . json_encode([
'timestamp' => date('Y-m-d H:i:s'),
'status' => $status,
'error' => $error,
]) . "\n\n";
@ob_flush(); flush();

}, 200, [
'Content-Type' => 'text/event-stream',
'Cache-Control' => 'no-cache',
'Connection' => 'keep-alive',
'X-Accel-Buffering' => 'no',
'Access-Control-Allow-Origin' => '*',
]);
}
}
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@
"vite": "^7.0.4"
},
"dependencies": {
"@headlessui/vue": "^1.7.23",
"@heroicons/vue": "^2.2.0",
"@inertiajs/vue3": "^2.1.7",
"@tailwindcss/forms": "^0.5.10",
"@vitejs/plugin-vue": "^6.0.1",
"@vueuse/core": "^13.9.0",
"vue": "^3.5.21"
Expand Down
25 changes: 25 additions & 0 deletions public/images/icons/square-settings.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading