File tree Expand file tree Collapse file tree 3 files changed +32
-0
lines changed
Expand file tree Collapse file tree 3 files changed +32
-0
lines changed Original file line number Diff line number Diff line change 1+ 'use strict' ;
2+
3+ const { createBenchmark } = require ( '../common.js' ) ;
4+ const bench = createBenchmark ( main , {
5+ n : 1_000_000 ,
6+ } ) ;
7+
8+ function main ( { n } ) {
9+ bench . start ( ) ;
10+ let sum = 0 ;
11+ for ( let i = 0 ; i < n ; i ++ ) {
12+ const result = Math . sin ( Math . PI * i ) * Math . cos ( Math . PI * i ) ;
13+ sum += result ; // eslint-disable-line no-unused-vars
14+ }
15+ bench . end ( n ) ;
16+ }
Original file line number Diff line number Diff line change 7777
7878 'v8_win64_unwinding_info' : 1 ,
7979
80+ 'v8_use_libm_trig_functions' : 1 ,
81+
8082 # Variables controlling external defines exposed in public headers.
8183 'v8_enable_map_packing%' : 0 ,
8284 'v8_enable_pointer_compression_shared_cage%' : 0 ,
Original file line number Diff line number Diff line change 1+ 'use strict' ;
2+
3+ require ( '../common' ) ;
4+ const { strictEqual } = require ( 'assert' ) ;
5+
6+ // Test to verify that the trig functions work as expected with the
7+ // v8_use_libm_trig_functions flag enabled.
8+ let sum = 0 ;
9+ for ( let i = 0 ; i < 1_000_000 ; i ++ ) {
10+ const result = Math . sin ( Math . PI * i ) * Math . cos ( Math . PI * i ) ;
11+ sum += result ;
12+ } ;
13+
14+ strictEqual ( sum , - 0.00006123284579142155 ) ;
You can’t perform that action at this time.
0 commit comments