mirror of
				https://github.com/NotAShelf/microfetch.git
				synced 2025-11-04 07:32:20 +00:00 
			
		
		
		
	add benchmarking
This commit is contained in:
		
					parent
					
						
							
								907112f2d1
							
						
					
				
			
			
				commit
				
					
						fabccd71e4
					
				
			
		
					 5 changed files with 621 additions and 0 deletions
				
			
		
							
								
								
									
										27
									
								
								benches/benchmark.rs
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										27
									
								
								benches/benchmark.rs
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,27 @@
 | 
			
		|||
use criterion::{criterion_group, criterion_main, Criterion};
 | 
			
		||||
use microfetch_lib::colors::print_dots;
 | 
			
		||||
use microfetch_lib::desktop::get_desktop_info;
 | 
			
		||||
use microfetch_lib::release::{get_os_pretty_name, get_system_info};
 | 
			
		||||
use microfetch_lib::system::{
 | 
			
		||||
    get_memory_usage, get_root_disk_usage, get_shell, get_username_and_hostname,
 | 
			
		||||
};
 | 
			
		||||
use microfetch_lib::uptime::get_current;
 | 
			
		||||
 | 
			
		||||
fn benchmark1(c: &mut Criterion) {
 | 
			
		||||
    let utsname = nix::sys::utsname::uname().expect("lol");
 | 
			
		||||
    c.bench_function("user_info", |b| {
 | 
			
		||||
        b.iter(|| get_username_and_hostname(&utsname))
 | 
			
		||||
    });
 | 
			
		||||
    c.bench_function("os_name", |b| b.iter(get_os_pretty_name));
 | 
			
		||||
    c.bench_function("kernel_version", |b| b.iter(|| get_system_info(&utsname)));
 | 
			
		||||
    c.bench_function("shell", |b| b.iter(get_shell));
 | 
			
		||||
 | 
			
		||||
    c.bench_function("desktop", |b| b.iter(get_desktop_info));
 | 
			
		||||
    c.bench_function("uptime", |b| b.iter(get_current));
 | 
			
		||||
    c.bench_function("memory_usage", |b| b.iter(get_memory_usage));
 | 
			
		||||
    c.bench_function("storage", |b| b.iter(get_root_disk_usage));
 | 
			
		||||
    c.bench_function("colors", |b| b.iter(print_dots));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
criterion_group!(benches, benchmark1);
 | 
			
		||||
criterion_main!(benches);
 | 
			
		||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue