dreamstack/examples/streaming-stats.ds

45 lines
929 B
Text
Raw Normal View History

-- DreamStack Streaming Stats
-- Tracks button presses and computes statistics.
-- Only total, average, max are exposed (sum and last_sample are internal).
--
-- Run with:
-- dreamstack stream examples/streaming-stats.ds --port 3003
let total = 0
let max = 0
let sum = 0
let average = sum / (total + 1)
stream stats on "ws://localhost:9100/peer/stats" {
mode: signal,
output: total, average, max
}
view stats =
column [
text "📊 Streaming Stats"
text "Samples: {total}"
text "Average: {average}"
text "Max: {max}"
row [
button "+5" {
click: total += 1
click: sum += 5
}
button "+10" {
click: total += 1
click: sum += 10
}
button "+25" {
click: total += 1
click: sum += 25
click: max = 25
}
button "+50" {
click: total += 1
click: sum += 50
click: max = 50
}
]
]