run cargo fmt
This commit is contained in:
parent
a45ddd2dc0
commit
c306083192
7
src/main/rust/Cargo.lock
generated
7
src/main/rust/Cargo.lock
generated
@ -332,6 +332,12 @@ version = "0.2.2"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7"
|
checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "easy-parallel"
|
||||||
|
version = "3.3.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "2afbb9b0aef60e4f0d2b18129b6c0dff035a6f7dbbd17c2f38c1432102ee223c"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "either"
|
name = "either"
|
||||||
version = "1.13.0"
|
version = "1.13.0"
|
||||||
@ -517,6 +523,7 @@ version = "0.1.0"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"bstr",
|
"bstr",
|
||||||
"criterion",
|
"criterion",
|
||||||
|
"easy-parallel",
|
||||||
"fast-float",
|
"fast-float",
|
||||||
"libc",
|
"libc",
|
||||||
"memchr",
|
"memchr",
|
||||||
|
@ -14,6 +14,7 @@ rayon = "1.10.0"
|
|||||||
rustc-hash = "2.0.0"
|
rustc-hash = "2.0.0"
|
||||||
libc = "0.2.158"
|
libc = "0.2.158"
|
||||||
smol = "2.0.1"
|
smol = "2.0.1"
|
||||||
|
easy-parallel = "3.3.1"
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
criterion = { version = "0.5.1", features = ["html_reports"] }
|
criterion = { version = "0.5.1", features = ["html_reports"] }
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
use criterion::{Criterion, criterion_group, criterion_main};
|
use criterion::{criterion_group, criterion_main, Criterion};
|
||||||
use onebrc::implementations::flare_flo::run;
|
use onebrc::implementations::flare_flo::run;
|
||||||
|
|
||||||
pub fn criterion_benchmark(c: &mut Criterion) {
|
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);
|
criterion_group!(benches, criterion_benchmark);
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
use criterion::{Criterion, criterion_group, criterion_main};
|
use criterion::{criterion_group, criterion_main, Criterion};
|
||||||
use onebrc::implementations::libraries::run;
|
use onebrc::implementations::libraries::run;
|
||||||
|
|
||||||
pub fn criterion_benchmark(c: &mut Criterion) {
|
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);
|
criterion_group!(benches, criterion_benchmark);
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
use criterion::{Criterion, criterion_group, criterion_main};
|
use criterion::{criterion_group, criterion_main, Criterion};
|
||||||
use onebrc::implementations::multi_threaded::run;
|
use onebrc::implementations::multi_threaded::run;
|
||||||
|
|
||||||
pub fn criterion_benchmark(c: &mut Criterion) {
|
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);
|
criterion_group!(benches, criterion_benchmark);
|
||||||
|
@ -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;
|
use onebrc::implementations::multi_threaded_smol::run;
|
||||||
|
|
||||||
pub fn criterion_benchmark(c: &mut Criterion) {
|
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);
|
criterion_group!(benches, criterion_benchmark);
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
use criterion::{Criterion, criterion_group, criterion_main};
|
use criterion::{criterion_group, criterion_main, Criterion};
|
||||||
use onebrc::implementations::phcs::run;
|
use onebrc::implementations::phcs::run;
|
||||||
|
|
||||||
pub fn criterion_benchmark(c: &mut Criterion) {
|
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);
|
criterion_group!(benches, criterion_benchmark);
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
use criterion::{Criterion, criterion_group, criterion_main};
|
use criterion::{criterion_group, criterion_main, Criterion};
|
||||||
use onebrc::implementations::reference_impl::run;
|
use onebrc::implementations::reference_impl::run;
|
||||||
|
|
||||||
pub fn criterion_benchmark(c: &mut Criterion) {
|
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);
|
criterion_group!(benches, criterion_benchmark);
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
use criterion::{Criterion, criterion_group, criterion_main};
|
use criterion::{criterion_group, criterion_main, Criterion};
|
||||||
use onebrc::implementations::single_thread::run;
|
use onebrc::implementations::single_thread::run;
|
||||||
|
|
||||||
pub fn criterion_benchmark(c: &mut Criterion) {
|
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);
|
criterion_group!(benches, criterion_benchmark);
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
use crate::models::station_measurements::StationMeasurements;
|
use crate::models::station_measurements::StationMeasurements;
|
||||||
use crate::utils::parse;
|
use crate::utils::parse;
|
||||||
|
use crate::utils::parse::hashstr;
|
||||||
use memmap2::MmapOptions;
|
use memmap2::MmapOptions;
|
||||||
|
use std::collections::HashMap;
|
||||||
use std::sync::mpsc;
|
use std::sync::mpsc;
|
||||||
use std::time::Instant;
|
use std::time::Instant;
|
||||||
use std::{fs::File, thread};
|
use std::{fs::File, thread};
|
||||||
use std::collections::HashMap;
|
|
||||||
use crate::utils::parse::hashstr;
|
|
||||||
|
|
||||||
const DEFAULT_HASHMAP_LENGTH: usize = 10000;
|
const DEFAULT_HASHMAP_LENGTH: usize = 10000;
|
||||||
|
|
||||||
@ -43,7 +43,7 @@ pub fn run() {
|
|||||||
s.spawn(move || {
|
s.spawn(move || {
|
||||||
let mut t_stations: HashMap<usize, (String, StationMeasurements)> =
|
let mut t_stations: HashMap<usize, (String, StationMeasurements)> =
|
||||||
HashMap::with_capacity(DEFAULT_HASHMAP_LENGTH);
|
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 {
|
if line.len() == 0 {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -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::collections::HashMap;
|
||||||
use std::io::{BufRead, Seek, SeekFrom};
|
use std::io::{BufRead, Seek, SeekFrom};
|
||||||
use std::sync::mpsc;
|
use std::sync::mpsc;
|
||||||
use std::time::Instant;
|
use std::time::Instant;
|
||||||
use std::{fs::File, io::BufReader, thread};
|
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;
|
const DEFAULT_HASHMAP_LENGTH: usize = 10000;
|
||||||
|
|
||||||
|
@ -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::sync::mpsc;
|
||||||
use std::time::Instant;
|
use std::time::Instant;
|
||||||
use std::{fs::File, thread};
|
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;
|
const DEFAULT_HASHMAP_LENGTH: usize = 10000;
|
||||||
|
|
||||||
@ -53,11 +53,16 @@ pub fn run() {
|
|||||||
let (station, temp) = unsafe { line.split_at_unchecked(100) };
|
let (station, temp) = unsafe { line.split_at_unchecked(100) };
|
||||||
let station = {
|
let station = {
|
||||||
if station[station.len() - 1] == 0u8 {
|
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 {
|
} else {
|
||||||
unsafe { std::str::from_utf8_unchecked(station) }
|
unsafe { std::str::from_utf8_unchecked(station) }
|
||||||
}
|
}
|
||||||
}.to_owned();
|
}
|
||||||
|
.to_owned();
|
||||||
let temp = parse::temp_new(&temp[1..6]);
|
let temp = parse::temp_new(&temp[1..6]);
|
||||||
let measurements_option = t_stations.get_mut(&station);
|
let measurements_option = t_stations.get_mut(&station);
|
||||||
if let Some(measurements) = measurements_option {
|
if let Some(measurements) = measurements_option {
|
||||||
|
@ -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::collections::HashMap;
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::io::{BufRead, BufReader};
|
use std::io::{BufRead, BufReader};
|
||||||
use std::time::Instant;
|
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;
|
const DEFAULT_HASHMAP_LENGTH: usize = 10000;
|
||||||
|
|
||||||
|
@ -3,6 +3,6 @@
|
|||||||
#![feature(slice_split_once)]
|
#![feature(slice_split_once)]
|
||||||
#![feature(hash_raw_entry)]
|
#![feature(hash_raw_entry)]
|
||||||
|
|
||||||
|
pub mod implementations;
|
||||||
pub mod models;
|
pub mod models;
|
||||||
pub mod utils;
|
pub mod utils;
|
||||||
pub mod implementations;
|
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
// let now = Instant::now();
|
// let now = Instant::now();
|
||||||
// let file = File::open("../../../measurements.txt").expect("File measurements.txt not found");
|
// let file = File::open("../../../measurements.txt").expect("File measurements.txt not found");
|
||||||
|
@ -1,2 +1,2 @@
|
|||||||
pub mod station_measurements;
|
|
||||||
pub mod mmap;
|
pub mod mmap;
|
||||||
|
pub mod station_measurements;
|
||||||
|
@ -3,7 +3,8 @@ use std::io::{BufRead, BufReader, BufWriter, Write};
|
|||||||
|
|
||||||
pub fn write_structured_measurements() {
|
pub fn write_structured_measurements() {
|
||||||
let file = File::open("../../../measurements.txt").expect("File measurements.txt not found");
|
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 reader = BufReader::new(&file);
|
||||||
let mut writer = BufWriter::new(&structured_file);
|
let mut writer = BufWriter::new(&structured_file);
|
||||||
let mut line = Vec::with_capacity(107);
|
let mut line = Vec::with_capacity(107);
|
||||||
@ -27,7 +28,9 @@ pub fn write_structured_measurements() {
|
|||||||
write_line[100] = b';';
|
write_line[100] = b';';
|
||||||
write_line[temp_val_start..temp_val_start + temp.len()].clone_from_slice(temp);
|
write_line[temp_val_start..temp_val_start + temp.len()].clone_from_slice(temp);
|
||||||
write_line[106] = b'\n';
|
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();
|
line.clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user