go test -v -run=^$ -bench=Benchmark_Session_Parallel -benchmem -count=4
(b *testing.B)
| 1439 | |
| 1440 | // go test -v -run=^$ -bench=Benchmark_Session_Parallel -benchmem -count=4 |
| 1441 | func Benchmark_Session_Parallel(b *testing.B) { |
| 1442 | b.Run("default", func(b *testing.B) { |
| 1443 | app, store := fiber.New(), NewStore() |
| 1444 | b.ReportAllocs() |
| 1445 | b.ResetTimer() |
| 1446 | b.RunParallel(func(pb *testing.PB) { |
| 1447 | for pb.Next() { |
| 1448 | c := app.AcquireCtx(&fasthttp.RequestCtx{}) |
| 1449 | c.Request().Header.SetCookie("session_id", "12356789") |
| 1450 | |
| 1451 | sess, _ := store.Get(c) //nolint:errcheck // We're inside a benchmark |
| 1452 | sess.Set("john", "doe") |
| 1453 | _ = sess.Save() //nolint:errcheck // We're inside a benchmark |
| 1454 | |
| 1455 | sess.Release() |
| 1456 | |
| 1457 | app.ReleaseCtx(c) |
| 1458 | } |
| 1459 | }) |
| 1460 | }) |
| 1461 | |
| 1462 | b.Run("storage", func(b *testing.B) { |
| 1463 | app := fiber.New() |
| 1464 | store := NewStore(Config{ |
| 1465 | Storage: memory.New(), |
| 1466 | }) |
| 1467 | b.ReportAllocs() |
| 1468 | b.ResetTimer() |
| 1469 | b.RunParallel(func(pb *testing.PB) { |
| 1470 | for pb.Next() { |
| 1471 | c := app.AcquireCtx(&fasthttp.RequestCtx{}) |
| 1472 | c.Request().Header.SetCookie("session_id", "12356789") |
| 1473 | |
| 1474 | sess, _ := store.Get(c) //nolint:errcheck // We're inside a benchmark |
| 1475 | sess.Set("john", "doe") |
| 1476 | _ = sess.Save() //nolint:errcheck // We're inside a benchmark |
| 1477 | |
| 1478 | sess.Release() |
| 1479 | |
| 1480 | app.ReleaseCtx(c) |
| 1481 | } |
| 1482 | }) |
| 1483 | }) |
| 1484 | } |
| 1485 | |
| 1486 | // go test -v -run=^$ -bench=Benchmark_Session_Asserted -benchmem -count=4 |
| 1487 | func Benchmark_Session_Asserted(b *testing.B) { |
nothing calls this directly
no test coverage detected