Skip to content

Commit 1b17071

Browse files
authored
bench: isolate operation
Signed-off-by: Athan <kgryte@gmail.com>
1 parent 8b9333f commit 1b17071

File tree

1 file changed

+4
-3
lines changed
  • lib/node_modules/@stdlib/number/float16/base/to-word/benchmark/c

1 file changed

+4
-3
lines changed

lib/node_modules/@stdlib/number/float16/base/to-word/benchmark/c/benchmark.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
#include "stdlib/number/float16/base/to_word.h"
2020
#include "stdlib/number/float64/base/to_float16.h"
21+
#include "stdlib/number/float64/ctor.h"
2122
#include <stdlib.h>
2223
#include <stdio.h>
2324
#include <stdint.h>
@@ -92,19 +93,19 @@ static double rand_double( void ) {
9293
* @return elapsed time in seconds
9394
*/
9495
static double benchmark( void ) {
95-
double x[ 100 ];
96+
stdlib_float16_t x[ 100 ];
9697
double elapsed;
9798
uint16_t w;
9899
double t;
99100
int i;
100101

101102
for ( i = 0; i < 100; i++ ) {
102-
x[ i ] = ( 1000.0*rand_double() ) - 500.0;
103+
x[ i ] = stdlib_base_float64_to_float16( ( 1000.0*rand_double() ) - 500.0 );
103104
}
104105

105106
t = tic();
106107
for ( i = 0; i < ITERATIONS; i++ ) {
107-
stdlib_base_float16_to_word( stdlib_base_float64_to_float16( x[ i % 100 ] ), &w );
108+
stdlib_base_float16_to_word( x[ i % 100 ], &w );
108109
if ( w == 1 ) { // Note: should not generate the smallest subnormal
109110
printf( "unexpected result\n" );
110111
break;

0 commit comments

Comments
 (0)