Remove stddev and direction columns
This commit is contained in:
parent
0d48e0791b
commit
2bf939186d
10 changed files with 32 additions and 116 deletions
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"db_name": "SQLite",
|
||||
"query": "SELECT metric, value, stddev, unit, direction FROM run_measurements WHERE id = ? ORDER BY metric ASC ",
|
||||
"query": "SELECT metric, value, unit FROM run_measurements WHERE id = ? ORDER BY metric ASC ",
|
||||
"describe": {
|
||||
"columns": [
|
||||
{
|
||||
|
|
@ -13,20 +13,10 @@
|
|||
"ordinal": 1,
|
||||
"type_info": "Float"
|
||||
},
|
||||
{
|
||||
"name": "stddev",
|
||||
"ordinal": 2,
|
||||
"type_info": "Float"
|
||||
},
|
||||
{
|
||||
"name": "unit",
|
||||
"ordinal": 3,
|
||||
"ordinal": 2,
|
||||
"type_info": "Text"
|
||||
},
|
||||
{
|
||||
"name": "direction",
|
||||
"ordinal": 4,
|
||||
"type_info": "Int64"
|
||||
}
|
||||
],
|
||||
"parameters": {
|
||||
|
|
@ -35,10 +25,8 @@
|
|||
"nullable": [
|
||||
false,
|
||||
false,
|
||||
true,
|
||||
true,
|
||||
true
|
||||
]
|
||||
},
|
||||
"hash": "0a4a3c4090e70ca643c4af0368ecf5c8dde66d898a900afa299a94e9a7bc62f8"
|
||||
"hash": "185c3516e116876f1783f25ffeb179ca6ecb4f9a001a48127516a81b7a50062a"
|
||||
}
|
||||
12
.sqlx/query-8fa4d1546e559bca47e2fb765ee33b989271492395b43c1887db7d490d9dff8d.json
generated
Normal file
12
.sqlx/query-8fa4d1546e559bca47e2fb765ee33b989271492395b43c1887db7d490d9dff8d.json
generated
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"db_name": "SQLite",
|
||||
"query": "INSERT INTO run_measurements ( id, metric, value, unit ) VALUES (?, ?, ?, ?) ",
|
||||
"describe": {
|
||||
"columns": [],
|
||||
"parameters": {
|
||||
"Right": 4
|
||||
},
|
||||
"nullable": []
|
||||
},
|
||||
"hash": "8fa4d1546e559bca47e2fb765ee33b989271492395b43c1887db7d490d9dff8d"
|
||||
}
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
{
|
||||
"db_name": "SQLite",
|
||||
"query": "INSERT INTO run_measurements ( id, metric, value, stddev, unit, direction ) VALUES (?, ?, ?, ?, ?, ?) ",
|
||||
"describe": {
|
||||
"columns": [],
|
||||
"parameters": {
|
||||
"Right": 6
|
||||
},
|
||||
"nullable": []
|
||||
},
|
||||
"hash": "971b811933eb0ab6ae4f23d6179f7035be88c7134b05118c20b106f10d299fe9"
|
||||
}
|
||||
|
|
@ -6,14 +6,9 @@ import json
|
|||
import math
|
||||
import re
|
||||
import sqlite3
|
||||
import statistics
|
||||
import urllib.request
|
||||
|
||||
DIRECTION = {
|
||||
"LESS_IS_BETTER": -1,
|
||||
"NEUTRAL": 0,
|
||||
"MORE_IS_BETTER": 1,
|
||||
}
|
||||
|
||||
|
||||
def format_time(time):
|
||||
# If the fractional part of the second is not exactly 3 or 6 digits long,
|
||||
|
|
@ -31,15 +26,6 @@ def format_time(time):
|
|||
return time.isoformat()
|
||||
|
||||
|
||||
def stddev(values):
|
||||
if len(values) < 2:
|
||||
return None
|
||||
N = len(values)
|
||||
mean = sum(values) / N
|
||||
variance = sum(pow(value - mean, 2) for value in values) / (N - 1)
|
||||
return math.sqrt(variance)
|
||||
|
||||
|
||||
def get_run_data(con, run_id):
|
||||
(
|
||||
runner_name,
|
||||
|
|
@ -73,7 +59,6 @@ def get_run_data(con, run_id):
|
|||
benchmark,
|
||||
metric,
|
||||
unit,
|
||||
interpretation,
|
||||
error,
|
||||
) in con.execute(
|
||||
"""
|
||||
|
|
@ -82,7 +67,6 @@ def get_run_data(con, run_id):
|
|||
benchmark,
|
||||
metric,
|
||||
unit,
|
||||
interpretation,
|
||||
error
|
||||
FROM measurement
|
||||
WHERE run_id = ?
|
||||
|
|
@ -101,10 +85,8 @@ def get_run_data(con, run_id):
|
|||
values = [value for (value,) in values]
|
||||
|
||||
measurements[f"{metric}/{benchmark}"] = {
|
||||
"value": sum(values),
|
||||
"stddev": stddev(values),
|
||||
"value": statistics.mean(values),
|
||||
"unit": unit,
|
||||
"direction": DIRECTION.get(interpretation),
|
||||
}
|
||||
|
||||
if error_type:
|
||||
|
|
|
|||
|
|
@ -43,9 +43,7 @@ CREATE TABLE run_measurements (
|
|||
id TEXT NOT NULL,
|
||||
metric TEXT NOT NULL,
|
||||
value REAL NOT NULL,
|
||||
stddev REAL,
|
||||
unit TEXT,
|
||||
direction INT,
|
||||
|
||||
PRIMARY KEY (id, metric),
|
||||
FOREIGN KEY (id) REFERENCES runs (id) ON DELETE CASCADE
|
||||
|
|
|
|||
|
|
@ -81,18 +81,14 @@ async fn save_work(
|
|||
id, \
|
||||
metric, \
|
||||
value, \
|
||||
stddev, \
|
||||
unit, \
|
||||
direction \
|
||||
unit \
|
||||
) \
|
||||
VALUES (?, ?, ?, ?, ?, ?) \
|
||||
VALUES (?, ?, ?, ?) \
|
||||
",
|
||||
run.id,
|
||||
metric,
|
||||
measurement.value,
|
||||
measurement.stddev,
|
||||
measurement.unit,
|
||||
measurement.direction,
|
||||
)
|
||||
.execute(&mut *conn)
|
||||
.await?;
|
||||
|
|
|
|||
|
|
@ -23,9 +23,7 @@ use crate::{
|
|||
struct Measurement {
|
||||
metric: String,
|
||||
value: String,
|
||||
stddev: String,
|
||||
unit: String,
|
||||
direction: &'static str,
|
||||
}
|
||||
|
||||
struct Line {
|
||||
|
|
@ -83,9 +81,7 @@ async fn from_finished_run(
|
|||
SELECT \
|
||||
metric, \
|
||||
value, \
|
||||
stddev, \
|
||||
unit, \
|
||||
direction \
|
||||
unit \
|
||||
FROM run_measurements \
|
||||
WHERE id = ? \
|
||||
ORDER BY metric ASC \
|
||||
|
|
@ -96,14 +92,7 @@ async fn from_finished_run(
|
|||
.map_ok(|r| Measurement {
|
||||
metric: r.metric,
|
||||
value: util::format_value(r.value),
|
||||
stddev: r.stddev.map(util::format_value).unwrap_or_default(),
|
||||
unit: r.unit.unwrap_or_default(),
|
||||
direction: match r.direction {
|
||||
Some(..=-1) => "less is better",
|
||||
Some(0) => "neutral",
|
||||
Some(1..) => "more is better",
|
||||
None => "",
|
||||
},
|
||||
})
|
||||
.try_collect::<Vec<_>>()
|
||||
.await?;
|
||||
|
|
|
|||
|
|
@ -55,14 +55,8 @@ pub enum Direction {
|
|||
pub struct Measurement {
|
||||
pub value: f64,
|
||||
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub stddev: Option<f64>,
|
||||
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub unit: Option<String>,
|
||||
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub direction: Option<Direction>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Serialize, Deserialize)]
|
||||
|
|
|
|||
|
|
@ -8,11 +8,7 @@ use std::{
|
|||
use regex::RegexBuilder;
|
||||
use walkdir::WalkDir;
|
||||
|
||||
use crate::{
|
||||
shared::{Direction, Measurement},
|
||||
somehow,
|
||||
worker::server::Server,
|
||||
};
|
||||
use crate::{shared::Measurement, somehow, worker::server::Server};
|
||||
|
||||
use super::{Finished, RunInProgress};
|
||||
|
||||
|
|
@ -110,70 +106,47 @@ fn count(path: &Path) -> somehow::Result<Counts> {
|
|||
Ok(counts)
|
||||
}
|
||||
|
||||
fn measurement(value: f64, direction: Direction) -> Measurement {
|
||||
Measurement {
|
||||
value,
|
||||
stddev: None,
|
||||
unit: None,
|
||||
direction: Some(direction),
|
||||
}
|
||||
fn measurement(value: f64) -> Measurement {
|
||||
Measurement { value, unit: None }
|
||||
}
|
||||
|
||||
fn measurements(counts: Counts) -> HashMap<String, Measurement> {
|
||||
let mut measurements = HashMap::new();
|
||||
|
||||
// Files
|
||||
measurements.insert(
|
||||
"files".to_string(),
|
||||
measurement(counts.files as f64, Direction::Neutral),
|
||||
);
|
||||
measurements.insert("files".to_string(), measurement(counts.files as f64));
|
||||
for (ext, count) in counts.files_by_ext {
|
||||
measurements.insert(
|
||||
format!("files/by extension/{ext}"),
|
||||
measurement(count as f64, Direction::Neutral),
|
||||
measurement(count as f64),
|
||||
);
|
||||
}
|
||||
for (dir, count) in counts.files_by_dir {
|
||||
measurements.insert(
|
||||
format!("files/by dir/{dir}/"),
|
||||
measurement(count as f64, Direction::Neutral),
|
||||
);
|
||||
measurements.insert(format!("files/by dir/{dir}/"), measurement(count as f64));
|
||||
}
|
||||
|
||||
// Lines
|
||||
measurements.insert(
|
||||
"lines".to_string(),
|
||||
measurement(counts.lines as f64, Direction::Neutral),
|
||||
);
|
||||
measurements.insert("lines".to_string(), measurement(counts.lines as f64));
|
||||
for (ext, count) in counts.lines_by_ext {
|
||||
measurements.insert(
|
||||
format!("lines/by extension/{ext}"),
|
||||
measurement(count as f64, Direction::Neutral),
|
||||
measurement(count as f64),
|
||||
);
|
||||
}
|
||||
for (dir, count) in counts.lines_by_dir {
|
||||
measurements.insert(
|
||||
format!("lines/by dir/{dir}/"),
|
||||
measurement(count as f64, Direction::Neutral),
|
||||
);
|
||||
measurements.insert(format!("lines/by dir/{dir}/"), measurement(count as f64));
|
||||
}
|
||||
|
||||
// Todos
|
||||
measurements.insert(
|
||||
"todos".to_string(),
|
||||
measurement(counts.todos as f64, Direction::LessIsBetter),
|
||||
);
|
||||
measurements.insert("todos".to_string(), measurement(counts.todos as f64));
|
||||
for (ext, count) in counts.todos_by_ext {
|
||||
measurements.insert(
|
||||
format!("todos/by extension/{ext}"),
|
||||
measurement(count as f64, Direction::LessIsBetter),
|
||||
measurement(count as f64),
|
||||
);
|
||||
}
|
||||
for (dir, count) in counts.todos_by_dir {
|
||||
measurements.insert(
|
||||
format!("todos/by dir/{dir}/"),
|
||||
measurement(count as f64, Direction::LessIsBetter),
|
||||
);
|
||||
measurements.insert(format!("todos/by dir/{dir}/"), measurement(count as f64));
|
||||
}
|
||||
|
||||
measurements
|
||||
|
|
|
|||
|
|
@ -36,9 +36,7 @@
|
|||
<tr>
|
||||
<th>metric</th>
|
||||
<th>value</th>
|
||||
<th>stddev</th>
|
||||
<th>unit</th>
|
||||
<th>direction</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
|
@ -46,9 +44,7 @@
|
|||
<tr>
|
||||
<td>{{ mm.metric }}</td>
|
||||
<td>{{ mm.value }}</td>
|
||||
<td>{{ mm.stddev }}</td>
|
||||
<td>{{ mm.unit }}</td>
|
||||
<td>{{ mm.direction }}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue