Guest User

Untitled

a guest
Jan 17th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. // metrics.count == 10000
  2. var metricsByStatus: Dictionary<String, Array<HKQuantitySample>> = ["low": [], "high": [], "normal": []]
  3.  
  4. // HKQuantitySample.status:
  5. func status(low: Double, high: Double) -> String {
  6. if value < low {
  7. return "low"
  8. } else if value > high {
  9. return "high"
  10. } else {
  11. return "normal"
  12. }
  13. }
  14.  
  15. // This is taking 1 second, 100% CPU
  16. for metric in metrics {
  17. metricsByStatus[metric.status(low: limits["low"], high: limits["high"])].append(metric)
  18. }
Add Comment
Please, Sign In to add comment