Speed up batch ADD and better bechmark
Now I flush only when the file is full and I check the the currently used file if it is big enough. So I dont get stat of all files and flush everytime like before
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
// This file is just to expose what I need to grab
|
||||
|
||||
pub const UUID = @import("uuid.zig").UUID;
|
||||
pub const Zero = @import("uuid.zig").zero;
|
||||
pub const DateTime = @import("date.zig").DateTime;
|
||||
pub const OR = @import("uuid.zig").OR;
|
||||
pub const AND = @import("uuid.zig").AND;
|
||||
|
||||
+6
-2
@@ -509,7 +509,7 @@ pub const ArrayIterator = struct {
|
||||
/// Performance concern once again.
|
||||
pub const DataWriter = struct {
|
||||
file: std.fs.File,
|
||||
writer: std.io.BufferedWriter(4096, std.fs.File.Writer),
|
||||
writer: std.io.BufferedWriter(4096, std.fs.File.Writer), // TODO: Increase buffer size, this should speed up a bit
|
||||
|
||||
pub fn init(name: []const u8, dir: ?std.fs.Dir) !DataWriter {
|
||||
const d_ = dir orelse std.fs.cwd();
|
||||
@@ -533,6 +533,10 @@ pub const DataWriter = struct {
|
||||
pub fn flush(self: *DataWriter) !void {
|
||||
try self.writer.flush();
|
||||
}
|
||||
|
||||
pub fn fileStat(self: DataWriter) !std.fs.File.Stat {
|
||||
return self.file.stat();
|
||||
}
|
||||
};
|
||||
|
||||
/// Create a new data file that can then be use by the DataWriter
|
||||
@@ -557,7 +561,7 @@ pub fn statFile(name: []const u8, dir: ?std.fs.Dir) !std.fs.File.Stat {
|
||||
// I have almost more lines of test than the real stuff x)
|
||||
// But I think everything is tested to be fair, so good stuff
|
||||
// It also write benchmark so you can benchmark on your own hardware
|
||||
// The data write and read is not really representative of real worl tho
|
||||
// The data write and read is not really representative of real world tho
|
||||
|
||||
test "Array Iterators" {
|
||||
const allocator = std.testing.allocator;
|
||||
|
||||
Reference in New Issue
Block a user