Files
intaleq/intaleq_driver/lib/controller/functions/performance_test.dart
T
Hamza-AyedandClaude Opus 5 0aab85c732 refactor: إعادة تسمية التطبيقات الأربعة siro_* → intaleq_*
المجلدات وأسماء حزم dart واستيراداتها:
  siro_rider → intaleq_rider    siro_driver  → intaleq_driver
  siro_admin → intaleq_admin    siro_service → intaleq_service

شمل ذلك `name:` في كل pubspec وكل `package:siro_*` في الاستيرادات
(115 ملفاً في rider وحده)، وإشارات أسماء المجلدات في docs/ وتعليق في
backend/Admin/notifications/broadcast.php. لم تبقَ إشارة واحدة (تحقّقت).

+ ضُمّت حزم get و get_storage داخل intaleq_driver/packages/ وحُوّلت
مساراتها الثلاثة من `../../Intaleq/packages/*` إلى `./packages/*`. كانت
تُحل عرضاً إلى مجلد App/Intaleq القديم المجاور — تبعية خارج المستودع
تنكسر بأول نقل. لم يبقَ في أي تطبيق تبعية مسار خارج الشجرة.

⚠️ لم تُمسّ بعد: هويات المتاجر (applicationId · PRODUCT_BUNDLE_IDENTIFIER ·
shorebird app_id) ولا الألوان ولا النصوص المرئية ولا النطاقات — كل منها
كوميت منفصل، والهويات تحتاج قرار المالك.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-07-27 16:10:58 +03:00

63 lines
2.2 KiB
Dart

import 'dart:io';
import 'dart:isolate';
class PerformanceTester {
/// ✅ فحص سرعة الكتابة إلى التخزين (Storage Write Speed) بوحدة MB/s
/// يكرر القياس عدة مرات ويأخذ المتوسط الوسيط لتقليل تأثير الحمل العرضي على الجهاز.
static Future<double> testStorageWriteSpeed({int samples = 3}) async {
final List<double> speeds = [];
for (int i = 0; i < samples; i++) {
try {
final tempDir = Directory.systemTemp;
final testFile = File('${tempDir.path}/speed_test_$i.txt');
final data = List<int>.filled(1024 * 1024 * 5, 0); // 5MB
final stopwatch = Stopwatch()..start();
await testFile.writeAsBytes(data, flush: true);
stopwatch.stop();
await testFile.delete();
double seconds = stopwatch.elapsedMilliseconds / 1000;
if (seconds == 0) seconds = 0.001;
speeds.add(5 / seconds);
} catch (e) {
print("❌ Storage write error: $e");
}
}
if (speeds.isEmpty) return 0.0;
speeds.sort();
final median = speeds[speeds.length ~/ 2];
return double.parse(median.toStringAsFixed(2));
}
/// عملية حسابية مكثفة تُنفَّذ داخل isolate منفصل حتى لا تجمّد واجهة المستخدم.
static double _cpuBurn(int iterations) {
double x = 0;
for (int i = 0; i < iterations; i++) {
x += i * 0.000001;
}
return x;
}
/// ✅ فحص سرعة المعالج (CPU Compute Speed) بوحدة الثواني
/// يعمل في isolate منفصل (لا يجمّد الواجهة) ويكرر القياس ويأخذ الوسيط.
static Future<double> testCPUSpeed({int samples = 3}) async {
try {
final List<double> times = [];
for (int i = 0; i < samples; i++) {
final stopwatch = Stopwatch()..start();
await Isolate.run(() => _cpuBurn(100000000));
stopwatch.stop();
times.add(stopwatch.elapsedMilliseconds / 1000.0);
}
times.sort();
return times[times.length ~/ 2];
} catch (e) {
print("❌ CPU compute error: $e");
return 999.0;
}
}
}