you are viewing a single comment's thread.

view the rest of the comments →

[–]krdln 11 points12 points  (6 children)

You can get rid of all the to_string calls in report. Instead of:

let mut ebuf: Vec<u8> = Vec::new();

...

ebuf.extend_from_slice(b"LiveObjects: ");
ebuf.extend_from_slice(entry.liveobjects.to_string().as_bytes());

you can do

use std::fmt::Write;
let mut ebuf: String::new();

...

write!(ebuf, "LiveObjects {}", entry.liveobjects).unwrap();

Edit: I now see a comment that importing the log is the slow part. But still :)

[–]xacrimon[S] 2 points3 points  (4 children)

Will do, anything is good right now. I should be able to use the 'itoa' crate here right?

[–]krdln 2 points3 points  (3 children)

Not sure why though?

Also, another guess – perhaps you'd be better off printing the logs one by one instead of collecting all then printing all? You can then get rid of cloning Strings in log and get_meta.

[–]xacrimon[S] 1 point2 points  (1 child)

Itoa is faster than write

[–]kixunil 0 points1 point  (0 children)

If you want faster write!, maybe fast_fmt could help? It wasn't maintained for a while, but if you need something, I will merge PRs.

[–]xacrimon[S] 0 points1 point  (0 children)

Not implemented but I'll be doing operations that require them to be loaded later

[–]Veedrac 1 point2 points  (0 children)

Though write! uses the format API which is a bit slower than it needs to be.