@@ -7,6 +7,7 @@ mod profile {
7
7
Ollama ,
8
8
} ;
9
9
pub use ollama_workflows:: Model ;
10
+ pub use prettytable:: { Cell , Row , Table } ;
10
11
pub use sysinfo:: { CpuRefreshKind , RefreshKind , System , MINIMUM_CPU_UPDATE_INTERVAL } ;
11
12
}
12
13
@@ -76,6 +77,18 @@ async fn main() {
76
77
let total_memory = system. total_memory ( ) ;
77
78
let used_memory = system. used_memory ( ) ;
78
79
let mut tps = 0 as f64 ;
80
+ let mut table = Table :: new ( ) ;
81
+
82
+ // Add a row with the headers
83
+ table. add_row ( Row :: new ( vec ! [
84
+ Cell :: new( "Model" ) ,
85
+ Cell :: new( "TPS" ) ,
86
+ Cell :: new( "OS" ) ,
87
+ Cell :: new( "Version" ) ,
88
+ Cell :: new( "CPU Usage (%)" ) ,
89
+ Cell :: new( "Total Memory (KB)" ) ,
90
+ Cell :: new( "Used Memory (KB)" ) ,
91
+ ] ) ) ;
79
92
80
93
for ( _, model) in cfg. models {
81
94
debug ! ( "Pulling model: {}" , model) ;
@@ -107,28 +120,29 @@ async fn main() {
107
120
match ollama. generate ( generation_request) . await {
108
121
Ok ( response) => {
109
122
debug ! ( "Got response for model {}" , model) ;
123
+
110
124
// compute TPS
111
125
tps = ( response. eval_count . unwrap_or_default ( ) as f64 )
112
126
/ ( response. eval_duration . unwrap_or ( 1 ) as f64 )
113
127
* 1_000_000_000f64 ;
114
- // report machine info
128
+
129
+ // add row to table
130
+ table. add_row ( Row :: new ( vec ! [
131
+ Cell :: new( & model. to_string( ) ) ,
132
+ Cell :: new( & tps. to_string( ) ) ,
133
+ Cell :: new( & format!( "{} {}" , brand, os_name) ) ,
134
+ Cell :: new( & os_version) ,
135
+ Cell :: new( & cpu_usage. to_string( ) ) ,
136
+ Cell :: new( & total_memory. to_string( ) ) ,
137
+ Cell :: new( & used_memory. to_string( ) ) ,
138
+ ] ) ) ;
115
139
}
116
140
Err ( e) => {
117
141
warn ! ( "Ignoring model {}: Workflow failed with error {}" , model, e) ;
118
142
}
119
143
}
144
+ table. printstd ( ) ;
120
145
// print system info
121
- println ! (
122
- "\n Model: {} \n TPS: {} \n OS: {} {} \n Version: {} \n CPU Usage: % {} \n Total Memory: {} KB \n Used Memory: {} KB " ,
123
- model,
124
- tps,
125
- brand,
126
- os_name,
127
- os_version,
128
- cpu_usage,
129
- total_memory,
130
- used_memory,
131
- ) ;
132
146
// refresh CPU usage (https://docs.rs/sysinfo/latest/sysinfo/struct.Cpu.html#method.cpu_usage)
133
147
system = System :: new_with_specifics (
134
148
RefreshKind :: new ( ) . with_cpu ( CpuRefreshKind :: everything ( ) ) ,
@@ -138,6 +152,8 @@ async fn main() {
138
152
// refresh CPUs again to get actual value
139
153
system. refresh_cpu_usage ( ) ;
140
154
}
155
+ // print system info
156
+ table. printstd ( ) ;
141
157
debug ! ( "Finished" ) ;
142
158
}
143
159
}
0 commit comments