OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2011 The Chromium OS Authors. All rights reserved. | 2 * Copyright (c) 2011 The Chromium OS Authors. All rights reserved. |
3 * Distributed under the terms of the GNU General Public License v2 | 3 * Distributed under the terms of the GNU General Public License v2 |
4 */ | 4 */ |
5 | 5 |
6 #include <stdio.h> | 6 #include <stdio.h> |
7 #include <string.h> | 7 #include <string.h> |
8 | 8 |
9 #include <style.h> | 9 #include <style.h> |
10 | 10 |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 max = counter->minute[i].peak; | 57 max = counter->minute[i].peak; |
58 } | 58 } |
59 } | 59 } |
60 counter->iminute = 0; | 60 counter->iminute = 0; |
61 counter->hour[counter->ihour].avg = average(sum, WHEEL_SIZE); | 61 counter->hour[counter->ihour].avg = average(sum, WHEEL_SIZE); |
62 counter->hour[counter->ihour].peak = max; | 62 counter->hour[counter->ihour].peak = max; |
63 if (++counter->ihour < WHEEL_SIZE) return; | 63 if (++counter->ihour < WHEEL_SIZE) return; |
64 counter->ihour = 0; | 64 counter->ihour = 0; |
65 ++counter->hour_wrapped; | 65 ++counter->hour_wrapped; |
66 } | 66 } |
67 | |
68 | |
69 | |
70 | 67 |
71 void dump_counter(TickCounter_s *counter) | 68 void dump_counter(TickCounter_s *counter) |
72 { | 69 { |
73 int i; | 70 int i; |
74 | 71 |
75 printf("Ticks: %d\n", counter->tick_size); | 72 printf("Ticks: %d\n", counter->tick_size); |
76 for (i = 0; i < counter->ticks_per_wheel; i++) { | 73 for (i = 0; i < counter->ticks_per_wheel; i++) { |
77 printf("%2i. %d %d\n", | 74 printf("%2i. %d %d\n", |
78 i, counter->tick[i], | 75 i, counter->tick[i], |
79 average(counter->tick[i], counter->tick_size)); | 76 average(counter->tick[i], counter->tick_size)); |
(...skipping 19 matching lines...) Expand all Loading... |
99 int i; | 96 int i; |
100 | 97 |
101 init_counter(&counter, 3); | 98 init_counter(&counter, 3); |
102 for (i = 0; i < 1000000; i++) { | 99 for (i = 0; i < 1000000; i++) { |
103 tick(&counter, range(21)); | 100 tick(&counter, range(21)); |
104 } | 101 } |
105 dump_counter(&counter); | 102 dump_counter(&counter); |
106 return 0; | 103 return 0; |
107 } | 104 } |
108 #endif | 105 #endif |
OLD | NEW |