File tree Expand file tree Collapse file tree 1 file changed +6
-7
lines changed
examples/tests/performance/sine Expand file tree Collapse file tree 1 file changed +6
-7
lines changed Original file line number Diff line number Diff line change @@ -7,13 +7,14 @@ FastSineGenerator<int16_t> sine_fast(32000);
7
7
int sec = 5 ;
8
8
9
9
size_t measure (int sec, SoundGenerator<int16_t > *gen){
10
- uint64_t end = millis ()+( 1000 *sec);
10
+ uint64_t start = millis ();
11
11
size_t count = 0 ;
12
- while ( millis ()<end ){
12
+ for ( int i= 0 ;i< 100000 ;i++ ){
13
13
int16_t s = gen->readSample ();
14
- count++;
15
14
}
16
- return count / sec;
15
+ uint64_t timeMs = millis ()-start;
16
+ // calculate samples per second
17
+ return 100.0 / timeMs;
17
18
}
18
19
19
20
const char * resultStr (const char * name, size_t count){
@@ -24,9 +25,7 @@ const char* resultStr(const char* name, size_t count){
24
25
25
26
void setup (){
26
27
Serial.begin (115200 );
27
- Serial.print (" Number of samples per sec during " );
28
- Serial.print (sec);
29
- Serial.println (" seconds:" );
28
+ Serial.print (" Number of samples per sec" );
30
29
}
31
30
32
31
void loop (){
You can’t perform that action at this time.
0 commit comments