عرض عملي: اختبار JMH كاذب ونسخته المصححة
في هذا الدرس 3 موضوعات
هذا الدرس مخطط له. يعرض المخطط أدناه الموضوعات التي سيغطيها، ولم يُنشر الدرس الكامل بعد.
نص الدروس والتمارين باللغة الإنجليزية، بينما تبقى واجهة الموقع وعناوين الدروس بالعربية.
في هذا الدرس
expose benchmark traps and fix them; prepares SRC-016-LAB1.
تفاصيل المخطط المبدئي
خطوة بخطوة
- Show a benchmark claiming a new parser is 100 times faster.
- Inspect: the result is unused (dead-code elimination) and input is a constant.
- Planned mistake: run it once in a plain
mainmethod with a stopwatch. Fix: use JMH with forks, warm-up, and measurement iterations. - Fix the benchmark: consume results through a
Blackhole, use varied input from@State. - Re-run: the true improvement is modest, with reported error bars.
- Add a note about what the microbenchmark does not show about the system.
اختبر فهمك
What suspicious sign did the first result show?
أظهر الإجابة
An implausibly large speedup, which suggested the work was optimized away.
التطبيق
طبّق هذا الدرس بمختبر الوحدة وتمارينها واختبارها.
تعليم الدرس كمكتمل اختياري ويمكنك التراجع عنه في أي وقت. يبقى تقدمك محفوظًا في هذا المتصفح.