Reference read

Perf:

$ time target/release/fast-fantoir FANTOIR0721

real	0m0,608s
user	0m0,526s
sys	0m0,081s

$ time target/debug/fast-fantoir FANTOIR0721

real	0m11,664s
user	0m11,549s
sys	0m0,113s

I highly suspect the release build to optimize out the useless file
read, partially explaining the *MASSIVE* perf difference between the
release build and the debug one.

This gives up a baseline speed order though. We should probably be
able to stay below 1 minute to generate the DB.
This commit is contained in:
Félix Baylac-Jacqué 2021-11-03 21:22:04 +01:00
commit e39f94bd25
Signed by: picnoir
GPG Key ID: EFD315F31848DBA4
6 changed files with 43 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
/target

7
Cargo.lock generated Normal file
View File

@ -0,0 +1,7 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 3
[[package]]
name = "fast-fantoir"
version = "0.1.0"

8
Cargo.toml Normal file
View File

@ -0,0 +1,8 @@
[package]
name = "fast-fantoir"
version = "0.1.0"
edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]

5
shell.nix Normal file
View File

@ -0,0 +1,5 @@
{ pkgs ? import <nixpkgs> {} }:
pkgs.mkShell {
nativeBuildInputs = [ pkgs.rustc pkgs.cargo ];
}

19
src/main.rs Normal file
View File

@ -0,0 +1,19 @@
use std::fs::File;
use std::io::{BufReader, BufRead};
fn main() -> std::io::Result<()> {
let fantoir_path = std::env::args().nth(1).unwrap();
let file = match File::open(&fantoir_path) {
Err(err) => panic!("Cannot read file {}: {}", fantoir_path, err),
Ok(file) => file,
};
let reader = BufReader::new(file);
for line in reader.lines() {
match line {
Ok(_l) => (),
Err(err) => panic!("Cannot read line: {}", err),
}
};
Ok(())
}

3
src/main.rs~ Normal file
View File

@ -0,0 +1,3 @@
fn main() {
println!("Hello, world!");
}