@@ -13,7 +13,7 @@ import (
1313 "time"
1414)
1515
16- // BenchmarkResult holds parsed benchmark result
16+ // BenchmarkResult хранит распарсенный результат бенчмарка.
1717type BenchmarkResult struct {
1818 Name string
1919 NsOp int64
@@ -22,15 +22,15 @@ type BenchmarkResult struct {
2222 Iterations int64
2323}
2424
25- // BenchmarkStandard defines expected performance standards
25+ // BenchmarkStandard описывает ожидаемые стандарты производительности.
2626type BenchmarkStandard struct {
2727 Name string
2828 Description string
2929 ExpectedNsOp int64
3030 Category string
3131}
3232
33- // Rating represents performance rating
33+ // Rating представляет оценку производительности.
3434type Rating string
3535
3636const (
@@ -41,7 +41,7 @@ const (
4141 RatingCritical Rating = "CRITICAL"
4242)
4343
44- // Color codes for terminal output
44+ // Цветовые коды для вывода в терминал.
4545const (
4646 colorReset = "\033 [0m"
4747 colorRed = "\033 [31m"
@@ -53,9 +53,9 @@ const (
5353 colorBold = "\033 [1m"
5454)
5555
56- // Standards defines expected performance for each benchmark
56+ // Standards описывает ожидаемую производительность для каждого бенчмарка.
5757var Standards = map [string ]BenchmarkStandard {
58- // API Benchmarks
58+ // Бенчмарки API
5959 "BenchmarkHealthEndpoint" : {
6060 Name : "Health Endpoint" ,
6161 Description : "Basic health check endpoint" ,
@@ -117,7 +117,7 @@ var Standards = map[string]BenchmarkStandard{
117117 Category : "API" ,
118118 },
119119
120- // Worker Benchmarks
120+ // Бенчмарки Worker
121121 "BenchmarkWorkerPool_ThroughputSmall" : {
122122 Name : "Worker Pool Small" ,
123123 Description : "2-4 workers, 100 matches" ,
@@ -161,7 +161,7 @@ var Standards = map[string]BenchmarkStandard{
161161 Category : "Worker" ,
162162 },
163163
164- // Queue Benchmarks
164+ // Бенчмарки Queue
165165 "BenchmarkQueueEnqueue" : {
166166 Name : "Queue Enqueue" ,
167167 Description : "Add match to Redis queue" ,
@@ -199,7 +199,7 @@ var Standards = map[string]BenchmarkStandard{
199199 Category : "Queue" ,
200200 },
201201
202- // Database Benchmarks
202+ // Бенчмарки БД
203203 "BenchmarkDBHealth" : {
204204 Name : "DB Health" ,
205205 Description : "Database health check" ,
@@ -305,25 +305,25 @@ func main() {
305305 fmt .Println ("Note: Only standalone benchmarks (no DB/Redis required)" )
306306 fmt .Println ()
307307
308- // Run only benchmarks that don't require external services
309- // Exclude : API (needs full server ), Queue (needs Redis), DB (needs Postgres)
310- // Include: Worker pool mocks , JSON parsing, UUID generation, Match creation
308+ // Запускаем только бенчмарки, которым не нужны внешние сервисы.
309+ // Исключаем : API (нужен полноценный сервер ), Queue (нужен Redis), DB (нужен Postgres).
310+ // Включаем: моки Worker pool, JSON parsing, UUID generation, Match creation.
311311 args := []string {
312312 "test" ,
313313 "-tags=benchmark" ,
314314 "-bench=" + * pattern ,
315315 "-benchmem" ,
316316 "-benchtime=500ms" ,
317317 "-timeout=30s" ,
318- "-run=^$" , // Don't run regular tests
318+ "-run=^$" , // Не запускать обычные тесты.
319319 "./tests/benchmark/..." ,
320320 }
321321 if * verbose {
322322 args = append (args , "-v" )
323323 }
324324
325- // #nosec G204 -- "go" hardcoded; args — hardcoded benchmark flags
326- // (bench regex, timeout, test path). CLI-utility, не server-endpoint .
325+ // #nosec G204 -- "go" hardcoded; args - hardcoded benchmark flags
326+ // (bench regex, timeout, test path). CLI-утилита, а не серверный эндпоинт .
327327 cmd := exec .Command ("go" , args ... )
328328 cmd .Dir = findProjectRoot ()
329329
@@ -334,7 +334,7 @@ func main() {
334334 err = cmd .Run ()
335335 output = stdout .Bytes ()
336336
337- // Print output in real-time for debugging
337+ // Печатаем вывод для отладки.
338338 if * verbose {
339339 fmt .Println (string (output ))
340340 }
@@ -346,7 +346,7 @@ func main() {
346346 }
347347 }
348348 } else {
349- // Read from stdin
349+ // Читаем из stdin.
350350 fmt .Println (colorCyan + "Reading benchmark results from stdin..." + colorReset )
351351 fmt .Println ("(Run with -run flag to execute benchmarks automatically)" )
352352 fmt .Println ()
@@ -375,20 +375,20 @@ func main() {
375375}
376376
377377func disableColors () {
378- // Can't reassign constants, so we'd need to use variables
379- // For simplicity, we'll skip this feature
378+ // Константы нельзя переопределить, потребовались бы переменные.
379+ // Для простоты эту фичу пропускаем.
380380}
381381
382382func findProjectRoot () string {
383- // Try to find go.mod
383+ // Пытаемся найти go.mod.
384384 dir , _ := os .Getwd ()
385385 return dir
386386}
387387
388388func parseBenchmarkOutput (output string ) []BenchmarkResult {
389389 var results []BenchmarkResult
390390
391- // Pattern : BenchmarkName-N iterations ns/op B/op allocs/op
391+ // Шаблон : BenchmarkName-N iterations ns/op B/op allocs/op.
392392 re := regexp .MustCompile (`(Benchmark\w+)(?:-\d+)?\s+(\d+)\s+([\d.]+)\s+ns/op(?:\s+([\d.]+)\s+B/op)?(?:\s+(\d+)\s+allocs/op)?` )
393393
394394 for _ , line := range strings .Split (output , "\n " ) {
@@ -476,7 +476,7 @@ func printResults(results []BenchmarkResult) {
476476 fmt .Println (colorBold + "================================================================================" + colorReset )
477477 fmt .Println ()
478478
479- // Group by category
479+ // Группируем по категориям.
480480 categories := map [string ][]BenchmarkResult {
481481 "API" : {},
482482 "Worker" : {},
@@ -537,7 +537,7 @@ func printResults(results []BenchmarkResult) {
537537 }
538538 }
539539
540- // Summary
540+ // Итоги.
541541 fmt .Println (colorBold + "================================================================================" + colorReset )
542542 fmt .Println (colorBold + " SUMMARY" + colorReset )
543543 fmt .Println (colorBold + "================================================================================" + colorReset )
@@ -553,7 +553,7 @@ func printResults(results []BenchmarkResult) {
553553 fmt .Printf (" %s---%s Critical (> 5.0x): %d\n " , colorRed , colorReset , ratings [RatingCritical ])
554554 fmt .Println ()
555555
556- // Recommendations
556+ // Рекомендации.
557557 if ratings [RatingCritical ] > 0 {
558558 fmt .Printf (" %s!!! CRITICAL:%s Some benchmarks are >5x slower than expected.\n " , colorRed , colorReset )
559559 fmt .Println (" Immediate investigation required!" )
0 commit comments