-
Notifications
You must be signed in to change notification settings - Fork 192
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add page iterator (LPI) for local pagination
* lpi package * part three, prev. commit: 5089413 Signed-off-by: Alex Aizman <[email protected]>
- Loading branch information
1 parent
5089413
commit 693ff5c
Showing
3 changed files
with
88 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// Package lpi: local page iterator | ||
/* | ||
* Copyright (c) 2025, NVIDIA CORPORATION. All rights reserved. | ||
*/ | ||
package lpi_test | ||
|
||
import ( | ||
"testing" | ||
) | ||
|
||
// [TODO] consider and bench lpi.Page alternatives: | ||
// - sorted (reusable) slice with binary search | ||
// - what else? | ||
|
||
func clearMap(m map[int]struct{}) { | ||
for k := range m { | ||
delete(m, k) | ||
} | ||
} | ||
|
||
func BenchmarkClearFunction(b *testing.B) { | ||
b.RunParallel(func(pb *testing.PB) { | ||
m := make(map[int]struct{}) | ||
for pb.Next() { | ||
for i := range 1000 { | ||
m[i] = struct{}{} | ||
} | ||
clear(m) | ||
} | ||
}) | ||
} | ||
|
||
func BenchmarkManualClear(b *testing.B) { | ||
b.RunParallel(func(pb *testing.PB) { | ||
m := make(map[int]struct{}) | ||
for pb.Next() { | ||
for i := range 1000 { | ||
m[i] = struct{}{} | ||
} | ||
clearMap(m) | ||
} | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters