run cargo fmt

This commit is contained in:
Fabian Schmidt 2024-08-27 13:24:14 +02:00
parent a45ddd2dc0
commit c306083192
18 changed files with 57 additions and 42 deletions

View File

@ -332,6 +332,12 @@ version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7"
[[package]]
name = "easy-parallel"
version = "3.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2afbb9b0aef60e4f0d2b18129b6c0dff035a6f7dbbd17c2f38c1432102ee223c"
[[package]]
name = "either"
version = "1.13.0"
@ -517,6 +523,7 @@ version = "0.1.0"
dependencies = [
"bstr",
"criterion",
"easy-parallel",
"fast-float",
"libc",
"memchr",

View File

@ -14,6 +14,7 @@ rayon = "1.10.0"
rustc-hash = "2.0.0"
libc = "0.2.158"
smol = "2.0.1"
easy-parallel = "3.3.1"
[dev-dependencies]
criterion = { version = "0.5.1", features = ["html_reports"] }

View File

@ -1,8 +1,8 @@
use criterion::{Criterion, criterion_group, criterion_main};
use criterion::{criterion_group, criterion_main, Criterion};
use onebrc::implementations::flare_flo::run;
pub fn criterion_benchmark(c: &mut Criterion) {
c.bench_function("flareflo", |b| {b.iter(|| run())});
c.bench_function("flareflo", |b| b.iter(|| run()));
}
criterion_group!(benches, criterion_benchmark);

View File

@ -1,8 +1,8 @@
use criterion::{Criterion, criterion_group, criterion_main};
use criterion::{criterion_group, criterion_main, Criterion};
use onebrc::implementations::libraries::run;
pub fn criterion_benchmark(c: &mut Criterion) {
c.bench_function("libraries", |b| {b.iter(|| run())});
c.bench_function("libraries", |b| b.iter(|| run()));
}
criterion_group!(benches, criterion_benchmark);

View File

@ -1,8 +1,8 @@
use criterion::{Criterion, criterion_group, criterion_main};
use criterion::{criterion_group, criterion_main, Criterion};
use onebrc::implementations::multi_threaded::run;
pub fn criterion_benchmark(c: &mut Criterion) {
c.bench_function("multithreaded", |b| {b.iter(|| run())});
c.bench_function("multithreaded", |b| b.iter(|| run()));
}
criterion_group!(benches, criterion_benchmark);

View File

@ -1,8 +1,8 @@
use criterion::{Criterion, criterion_group, criterion_main};
use criterion::{criterion_group, criterion_main, Criterion};
use onebrc::implementations::multi_threaded_smol::run;
pub fn criterion_benchmark(c: &mut Criterion) {
c.bench_function("multithreadedsmol", |b| {b.iter(|| run())});
c.bench_function("multithreadedsmol", |b| b.iter(|| run()));
}
criterion_group!(benches, criterion_benchmark);

View File

@ -1,8 +1,8 @@
use criterion::{Criterion, criterion_group, criterion_main};
use criterion::{criterion_group, criterion_main, Criterion};
use onebrc::implementations::phcs::run;
pub fn criterion_benchmark(c: &mut Criterion) {
c.bench_function("phcs", |b| {b.iter(|| run())});
c.bench_function("phcs", |b| b.iter(|| run()));
}
criterion_group!(benches, criterion_benchmark);

View File

@ -1,8 +1,8 @@
use criterion::{Criterion, criterion_group, criterion_main};
use criterion::{criterion_group, criterion_main, Criterion};
use onebrc::implementations::reference_impl::run;
pub fn criterion_benchmark(c: &mut Criterion) {
c.bench_function("reference", |b| {b.iter(|| run())});
c.bench_function("reference", |b| b.iter(|| run()));
}
criterion_group!(benches, criterion_benchmark);

View File

@ -1,8 +1,8 @@
use criterion::{Criterion, criterion_group, criterion_main};
use criterion::{criterion_group, criterion_main, Criterion};
use onebrc::implementations::single_thread::run;
pub fn criterion_benchmark(c: &mut Criterion) {
c.bench_function("singlethread", |b| {b.iter(|| run())});
c.bench_function("singlethread", |b| b.iter(|| run()));
}
criterion_group!(benches, criterion_benchmark);

View File

@ -1,11 +1,11 @@
use crate::models::station_measurements::StationMeasurements;
use crate::utils::parse;
use crate::utils::parse::hashstr;
use memmap2::MmapOptions;
use std::collections::HashMap;
use std::sync::mpsc;
use std::time::Instant;
use std::{fs::File, thread};
use std::collections::HashMap;
use crate::utils::parse::hashstr;
const DEFAULT_HASHMAP_LENGTH: usize = 10000;
@ -43,7 +43,7 @@ pub fn run() {
s.spawn(move || {
let mut t_stations: HashMap<usize, (String, StationMeasurements)> =
HashMap::with_capacity(DEFAULT_HASHMAP_LENGTH);
for line in mmap_slice.split(|&byte| { byte == b'\n' }) {
for line in mmap_slice.split(|&byte| byte == b'\n') {
if line.len() == 0 {
break;
}

View File

@ -1,11 +1,11 @@
use crate::models::station_measurements::StationMeasurements;
use crate::utils::parse;
use crate::utils::parse::hashstr;
use std::collections::HashMap;
use std::io::{BufRead, Seek, SeekFrom};
use std::sync::mpsc;
use std::time::Instant;
use std::{fs::File, io::BufReader, thread};
use crate::models::station_measurements::StationMeasurements;
use crate::utils::parse;
use crate::utils::parse::hashstr;
const DEFAULT_HASHMAP_LENGTH: usize = 10000;

View File

@ -1,11 +1,11 @@
use crate::models::station_measurements::StationMeasurements;
use crate::utils::parse;
use memmap2::MmapOptions;
use rustc_hash::{FxBuildHasher, FxHashMap};
use std::ffi::CStr;
use std::sync::mpsc;
use std::time::Instant;
use std::{fs::File, thread};
use std::ffi::CStr;
use memmap2::MmapOptions;
use rustc_hash::{FxBuildHasher, FxHashMap};
use crate::models::station_measurements::StationMeasurements;
use crate::utils::parse;
const DEFAULT_HASHMAP_LENGTH: usize = 10000;
@ -53,11 +53,16 @@ pub fn run() {
let (station, temp) = unsafe { line.split_at_unchecked(100) };
let station = {
if station[station.len() - 1] == 0u8 {
unsafe { std::str::from_utf8_unchecked(CStr::from_bytes_until_nul(station).unwrap().to_bytes()) }
unsafe {
std::str::from_utf8_unchecked(
CStr::from_bytes_until_nul(station).unwrap().to_bytes(),
)
}
} else {
unsafe { std::str::from_utf8_unchecked(station) }
}
}.to_owned();
}
.to_owned();
let temp = parse::temp_new(&temp[1..6]);
let measurements_option = t_stations.get_mut(&station);
if let Some(measurements) = measurements_option {

View File

@ -1,10 +1,10 @@
use crate::models::station_measurements::StationMeasurements;
use crate::utils::parse;
use crate::utils::parse::hashstr;
use std::collections::HashMap;
use std::fs::File;
use std::io::{BufRead, BufReader};
use std::time::Instant;
use crate::models::station_measurements::StationMeasurements;
use crate::utils::parse;
use crate::utils::parse::hashstr;
const DEFAULT_HASHMAP_LENGTH: usize = 10000;

View File

@ -3,6 +3,6 @@
#![feature(slice_split_once)]
#![feature(hash_raw_entry)]
pub mod implementations;
pub mod models;
pub mod utils;
pub mod implementations;

View File

@ -1,4 +1,3 @@
fn main() {
// let now = Instant::now();
// let file = File::open("../../../measurements.txt").expect("File measurements.txt not found");

View File

@ -1,2 +1,2 @@
pub mod station_measurements;
pub mod mmap;
pub mod station_measurements;

View File

@ -3,7 +3,8 @@ use std::io::{BufRead, BufReader, BufWriter, Write};
pub fn write_structured_measurements() {
let file = File::open("../../../measurements.txt").expect("File measurements.txt not found");
let structured_file = File::create_new("structured_measurements.txt").expect("Could not create file");
let structured_file =
File::create_new("structured_measurements.txt").expect("Could not create file");
let mut reader = BufReader::new(&file);
let mut writer = BufWriter::new(&structured_file);
let mut line = Vec::with_capacity(107);
@ -27,7 +28,9 @@ pub fn write_structured_measurements() {
write_line[100] = b';';
write_line[temp_val_start..temp_val_start + temp.len()].clone_from_slice(temp);
write_line[106] = b'\n';
writer.write_all(write_line.as_slice()).expect("Could not write");
writer
.write_all(write_line.as_slice())
.expect("Could not write");
line.clear();
}
}