Skip to content

Commit 596fc56

Browse files
committed
return_Self__no_clone
1 parent 41ce3fc commit 596fc56

File tree

2 files changed

+154
-146
lines changed

2 files changed

+154
-146
lines changed

src/bench.zig

Lines changed: 36 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,7 @@ pub fn benchSTR(N: usize) !void {
1515
var allocatorA = arena.allocator();
1616
defer arena.deinit();
1717

18-
const SL2 = SortedMap([]const u8, []const u8, .set);
19-
var sL: SL2 = .{};
20-
21-
try sL.init(allocatorG);
18+
var sL = try SortedMap([]const u8, []const u8, .set).init(allocatorG);
2219
defer sL.deinit();
2320

2421
var keys = std.ArrayList([]const u8).init(allocatorA);
@@ -87,7 +84,7 @@ pub fn benchSTR(N: usize) !void {
8784
// Clear the sL
8885
assert(sL.size == 98);
8986
try sL.clearRetainingCapacity();
90-
arenaCacheSizeQuery(&sL.cache);
87+
arenaCacheSizeQuery(&sL.cache_());
9188

9289
// ------------------ EXCHANGE -------------------//
9390
// -- read 10, insert 40, remove 40, update 10 -- //
@@ -143,7 +140,7 @@ pub fn benchSTR(N: usize) !void {
143140
// Clear the sL
144141
assert(sL.size == 10);
145142
try sL.clearRetainingCapacity();
146-
arenaCacheSizeQuery(&sL.cache);
143+
arenaCacheSizeQuery(&sL.cache_());
147144

148145
// --------------- EXCHANGE HEAVY --------------//
149146
// -- read 1, insert 98, remove 98, update 1 -- //
@@ -199,7 +196,7 @@ pub fn benchSTR(N: usize) !void {
199196
// Clear the sL
200197
assert(sL.size == 1);
201198
try sL.clearRetainingCapacity();
202-
arenaCacheSizeQuery(&sL.cache);
199+
arenaCacheSizeQuery(&sL.cache_());
203200

204201
// ---------------- RAPID GROW -----------------//
205202
// -- read 5, insert 80, remove 5, update 10 -- //
@@ -251,29 +248,30 @@ pub fn benchSTR(N: usize) !void {
251248
// Print stats //
252249
// Test' individual stats
253250
try writeStamps("RG", N, time);
254-
arenaCacheSizeQuery(&sL.cache);
251+
arenaCacheSizeQuery(&sL.cache_());
255252

256253
// ---------------- CLONING -----------------//
257254
// ------ obtain a clone of the graph ------ //
258255

259256
// Clear the time, re-start the timer
260-
time = 0;
261-
timer = try std.time.Timer.start();
262-
start = timer.lap();
257+
// time = 0;
258+
// timer = try std.time.Timer.start();
259+
// start = timer.lap();
263260

264-
var clone = try sL.clone();
265-
defer clone.deinit();
261+
// var clone = try sL.clone();
262+
// defer clone.deinit();
266263

267-
end = timer.read();
268-
time += end -| start;
269-
aggregate += time;
264+
// end = timer.read();
265+
// time += end -| start;
266+
// aggregate += time;
270267

271-
// Print stats //
272-
// Test' individual stats
273-
try writeStamps("CLONE", clone.size, time);
268+
// // Print stats //
269+
// // Test' individual stats
270+
// try writeStamps("CLONE", clone.size, time);
274271

275272
// Aggregate stats
276-
try writeStamps("aggregate", N * 4 + clone.size, aggregate);
273+
// try writeStamps("aggregate", N * 4 + clone.size, aggregate);
274+
try writeStamps("aggregate", N * 4, aggregate);
277275
try stdout.print("\n", .{});
278276
}
279277

@@ -288,10 +286,7 @@ pub fn benchU64(N: usize) !void {
288286
var allocatorA = arena.allocator();
289287
defer arena.deinit();
290288

291-
const SL = SortedMap(u64, u64, .set);
292-
var sL: SL = .{};
293-
294-
try sL.init(allocatorG);
289+
var sL = try SortedMap(u64, u64, .set).init(allocatorG);
295290
defer sL.deinit();
296291

297292
// try sL.ensureTotalCapacity(N);
@@ -357,7 +352,7 @@ pub fn benchU64(N: usize) !void {
357352
// Clear the sL
358353
assert(sL.size == 98);
359354
try sL.clearRetainingCapacity();
360-
arenaCacheSizeQuery(&sL.cache);
355+
arenaCacheSizeQuery(&sL.cache_());
361356

362357
// ------------------ EXCHANGE -------------------//
363358
// -- read 10, insert 40, remove 40, update 10 -- //
@@ -412,7 +407,7 @@ pub fn benchU64(N: usize) !void {
412407
// Clear the sL
413408
assert(sL.size == 10);
414409
try sL.clearRetainingCapacity();
415-
arenaCacheSizeQuery(&sL.cache);
410+
arenaCacheSizeQuery(&sL.cache_());
416411

417412
// --------------- EXCHANGE HEAVY --------------//
418413
// -- read 1, insert 98, remove 98, update 1 -- //
@@ -467,7 +462,7 @@ pub fn benchU64(N: usize) !void {
467462
// Clear the sL
468463
assert(sL.size == 1);
469464
try sL.clearRetainingCapacity();
470-
arenaCacheSizeQuery(&sL.cache);
465+
arenaCacheSizeQuery(&sL.cache_());
471466

472467
// ---------------- RAPID GROW -----------------//
473468
// -- read 5, insert 80, remove 5, update 10 -- //
@@ -518,29 +513,30 @@ pub fn benchU64(N: usize) !void {
518513
// Print stats //
519514
// Test' individual stats
520515
try writeStamps("RG", N, time);
521-
arenaCacheSizeQuery(&sL.cache);
516+
arenaCacheSizeQuery(&sL.cache_());
522517

523518
// ---------------- CLONING -----------------//
524519
// ------ obtain a clone of the graph ------ //
525520

526521
// Clear the time, re-start the timer
527-
time = 0;
528-
timer = try std.time.Timer.start();
529-
start = timer.lap();
522+
// time = 0;
523+
// timer = try std.time.Timer.start();
524+
// start = timer.lap();
530525

531-
var clone = try sL.clone();
532-
defer clone.deinit();
526+
// var clone = try sL.clone();
527+
// defer clone.deinit();
533528

534-
end = timer.read();
535-
time += end -| start;
536-
aggregate += time;
529+
// end = timer.read();
530+
// time += end -| start;
531+
// aggregate += time;
537532

538-
// Print stats //
539-
// Test' individual stats
540-
try writeStamps("CLONE", clone.size, time);
533+
// // Print stats //
534+
// // Test' individual stats
535+
// try writeStamps("CLONE", clone.size, time);
541536

542537
// Aggregate stats
543-
try writeStamps("aggregate", N * 4 + clone.size, aggregate);
538+
// try writeStamps("aggregate", N * 4 + clone.size, aggregate);
539+
try writeStamps("aggregate", N * 4, aggregate);
544540
try stdout.print("\n", .{});
545541
}
546542

0 commit comments

Comments
 (0)