blob: 6609adbf7dfd11a11e76325f4762af7981706a4b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
package benchmark_core_crypto
import "core:crypto"
import "core:fmt"
import "core:log"
import "core:strings"
import "core:text/table"
import "core:time"
@(private)
log_table :: #force_inline proc(tbl: ^table.Table) {
sb := strings.builder_make()
defer strings.builder_destroy(&sb)
wr := strings.to_writer(&sb)
fmt.sbprintln(&sb)
table.write_plain_table(wr, tbl)
log.info(strings.to_string(sb))
}
@(private)
setup_sized_buf :: proc(
options: ^time.Benchmark_Options,
allocator := context.allocator,
) -> (
err: time.Benchmark_Error,
) {
assert(options != nil)
options.input = make([]u8, options.bytes, allocator)
if len(options.input) > 0 {
crypto.rand_bytes(options.input)
}
return nil if len(options.input) == options.bytes else .Allocation_Error
}
@(private)
teardown_sized_buf :: proc(
options: ^time.Benchmark_Options,
allocator := context.allocator,
) -> (
err: time.Benchmark_Error,
) {
assert(options != nil)
delete(options.input)
return nil
}
|