Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // metrics.count == 10000
- var metricsByStatus: Dictionary<String, Array<HKQuantitySample>> = ["low": [], "high": [], "normal": []]
- // HKQuantitySample.status:
- func status(low: Double, high: Double) -> String {
- if value < low {
- return "low"
- } else if value > high {
- return "high"
- } else {
- return "normal"
- }
- }
- // This is taking 1 second, 100% CPU
- for metric in metrics {
- metricsByStatus[metric.status(low: limits["low"], high: limits["high"])].append(metric)
- }
Add Comment
Please, Sign In to add comment