File tree 1 file changed +8
-3
lines changed
bench/algorithm/binarytrees
1 file changed +8
-3
lines changed Original file line number Diff line number Diff line change @@ -7,16 +7,21 @@ const MIN_DEPTH = 4;
7
7
const global_allocator = std .heap .c_allocator ;
8
8
9
9
pub fn main () ! void {
10
+ var arena = std .heap .ArenaAllocator .init (global_allocator );
11
+ defer arena .deinit ();
12
+
13
+ var allocator = arena .allocator ();
14
+
10
15
const stdout = std .io .getStdOut ().writer ();
11
16
const n = try get_n ();
12
17
const max_depth = @max (MIN_DEPTH + 2 , n );
13
18
{
14
19
const stretch_depth = max_depth + 1 ;
15
- const stretch_tree = Node .make (stretch_depth , global_allocator ).? ;
20
+ const stretch_tree = Node .make (stretch_depth , allocator ).? ;
16
21
defer stretch_tree .deinit ();
17
22
try stdout .print ("stretch tree of depth {d}\t check: {d}\n " , .{ stretch_depth , stretch_tree .check () });
18
23
}
19
- const long_lived_tree = Node .make (max_depth , global_allocator ).? ;
24
+ const long_lived_tree = Node .make (max_depth , allocator ).? ;
20
25
defer long_lived_tree .deinit ();
21
26
22
27
var depth : usize = MIN_DEPTH ;
@@ -25,7 +30,7 @@ pub fn main() !void {
25
30
var sum : usize = 0 ;
26
31
var i : usize = 0 ;
27
32
while (i < iterations ) : (i += 1 ) {
28
- const tree = Node .make (depth , global_allocator ).? ;
33
+ const tree = Node .make (depth , allocator ).? ;
29
34
defer tree .deinit ();
30
35
sum += tree .check ();
31
36
}
You can’t perform that action at this time.
0 commit comments