1
1
#[ cfg( feature = "profiling" ) ]
2
2
mod profile {
3
3
pub use dkn_workflows:: { DriaWorkflowsConfig , OllamaConfig } ;
4
+ pub use log:: { debug, warn} ;
4
5
pub use ollama_workflows:: ollama_rs:: {
5
6
generation:: { completion:: request:: GenerationRequest , options:: GenerationOptions } ,
6
7
Ollama ,
@@ -61,26 +62,27 @@ async fn main() {
61
62
let cfg = DriaWorkflowsConfig :: new ( models) ;
62
63
let config = OllamaConfig :: default ( ) ;
63
64
let ollama = Ollama :: new ( config. host , config. port ) ;
64
- log :: info !( "Starting..." ) ;
65
+ debug ! ( "Starting..." ) ;
65
66
// ensure that all lists of CPUs and processes are filled
66
67
let mut system = System :: new_all ( ) ;
67
68
// update all information of the system
68
69
system. refresh_all ( ) ;
69
70
70
- log :: debug!( "Getting system information..." ) ;
71
+ debug ! ( "Getting system information..." ) ;
71
72
let brand = system. cpus ( ) [ 0 ] . brand ( ) . to_string ( ) ;
72
73
let os_name = System :: name ( ) . unwrap_or_else ( || "Unknown" . to_string ( ) ) ;
73
74
let os_version = System :: long_os_version ( ) . unwrap_or_else ( || "Unknown" . to_string ( ) ) ;
74
75
let cpu_usage = system. global_cpu_usage ( ) ;
75
76
let total_memory = system. total_memory ( ) ;
76
77
let used_memory = system. used_memory ( ) ;
78
+ let mut tps = 0 as f64 ;
77
79
78
80
for ( _, model) in cfg. models {
79
- log :: info !( "Pulling model: {}" , model) ;
81
+ debug ! ( "Pulling model: {}" , model) ;
80
82
81
83
// pull model
82
84
match ollama. pull_model ( model. to_string ( ) , false ) . await {
83
- Ok ( status) => log :: info !( "Status: {}" , status. message) ,
85
+ Ok ( status) => debug ! ( "Status: {}" , status. message) ,
84
86
Err ( err) => {
85
87
log:: error!( "Failed to pull model {}: {:?}" , model, err) ;
86
88
}
@@ -104,13 +106,19 @@ async fn main() {
104
106
// generate response
105
107
match ollama. generate ( generation_request) . await {
106
108
Ok ( response) => {
107
- log :: debug!( "Got response for model {}" , model) ;
109
+ debug ! ( "Got response for model {}" , model) ;
108
110
// compute TPS
109
- let tps = ( response. eval_count . unwrap_or_default ( ) as f64 )
111
+ tps = ( response. eval_count . unwrap_or_default ( ) as f64 )
110
112
/ ( response. eval_duration . unwrap_or ( 1 ) as f64 )
111
113
* 1_000_000_000f64 ;
112
114
// report machine info
113
- log:: info!(
115
+ }
116
+ Err ( e) => {
117
+ warn ! ( "Ignoring model {}: Workflow failed with error {}" , model, e) ;
118
+ }
119
+ }
120
+ // print system info
121
+ println ! (
114
122
"\n Model: {} \n TPS: {} \n OS: {} {} \n Version: {} \n CPU Usage: % {} \n Total Memory: {} KB \n Used Memory: {} KB " ,
115
123
model,
116
124
tps,
@@ -121,11 +129,6 @@ async fn main() {
121
129
total_memory,
122
130
used_memory,
123
131
) ;
124
- }
125
- Err ( e) => {
126
- log:: warn!( "Ignoring model {}: Workflow failed with error {}" , model, e) ;
127
- }
128
- }
129
132
// refresh CPU usage (https://docs.rs/sysinfo/latest/sysinfo/struct.Cpu.html#method.cpu_usage)
130
133
system = System :: new_with_specifics (
131
134
RefreshKind :: new ( ) . with_cpu ( CpuRefreshKind :: everything ( ) ) ,
@@ -135,6 +138,6 @@ async fn main() {
135
138
// refresh CPUs again to get actual value
136
139
system. refresh_cpu_usage ( ) ;
137
140
}
141
+ debug ! ( "Finished" ) ;
138
142
}
139
- log:: info!( "Finished" ) ;
140
143
}
0 commit comments