add benchmark

This commit is contained in:
Dr. Matthias Ratajczak
2023-01-04 12:55:56 +01:00
parent 9c276ed5e9
commit ec07aba204
4 changed files with 383 additions and 0 deletions
+19
View File
@@ -0,0 +1,19 @@
use criterion::{black_box, criterion_group, criterion_main, Criterion};
use departure::response::Response;
use std::fs::read_to_string;
fn load_json() -> String {
read_to_string("benches/reply.json").unwrap()
}
fn criterion_benchmark(c: &mut Criterion) {
let content = load_json();
c.bench_function("parse JSON", |b| {
b.iter(|| serde_json::from_str::<'_, Response>(black_box(&content)))
});
}
criterion_group!(benches, criterion_benchmark);
criterion_main!(benches);
+1
View File
@@ -0,0 +1 @@
{"Name":"Forschungszentrum","Status":{"Code":"Ok"},"Place":"Rossendorf (Dresden)","ExpirationTime":"\/Date(1672832857580+0100)\/","Departures":[{"Id":"voe:27753: :R:j23","DlId":"de:vvo:27-753","LineName":"753","Direction":"Radeberg Bahnhof","Platform":{"Name":"1","Type":"Platform"},"Mot":"IntercityBus","RealTime":"\/Date(1672832760000-0000)\/","ScheduledTime":"\/Date(1672832400000-0000)\/","State":"Delayed","RouteChanges":[],"Diva":{"Number":"27753","Network":"voe"},"CancelReasons":[]},{"Id":"voe:15261:b:R:j23","DlId":"de:vvo:15-261-b","LineName":"261","Direction":"Sebnitz Busbahnhof","Platform":{"Name":"2","Type":"Platform"},"Mot":"PlusBus","RealTime":"\/Date(1672833120000-0000)\/","ScheduledTime":"\/Date(1672833060000-0000)\/","State":"Delayed","RouteChanges":[],"Diva":{"Number":"15261b","Network":"voe"},"CancelReasons":[]}]}