File: strtod

package info (click to toggle)
opencascade 7.9.2%2Bdfsg-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 301,924 kB
  • sloc: cpp: 1,523,264; tcl: 10,159; cs: 5,173; java: 1,554; sh: 1,342; ansic: 827; xml: 699; makefile: 30; javascript: 22
file content (50 lines) | stat: -rw-r--r-- 1,823 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
puts "================================================================="
puts "Testing performance of Strtod() vs. standard strtod()"
puts "================================================================="
puts ""

puts "TODO ?CR33225 Linux: is expected to be at least "

pload QAcommands

# Check that performance of Strtod() and Atof() is at least twice better 
# than that of standard strtod() and atof()
proc CheckAtof {nbvalues nbdigits min max} {
  set res [QATestAtof $nbvalues $nbdigits $min $max]
#  puts $res

  if { ! [regexp {atof\s+([0-9.]+)} $res bidon cpu_atof] ||
       ! [regexp {Atof\s+([0-9.]+)} $res bidon cpu_Atof] ||
       ! [regexp {strtod\s+([0-9.]+)} $res bidon cpu_strtod] ||
       ! [regexp {Strtod\s+([0-9.]+)} $res bidon cpu_Strtod] } {
    puts "Error: cannot interpret results of test command!"
  } else {
    if { $cpu_atof < 1.5 * $cpu_Atof } {
      puts "Error: Atof() is expected to be at least 2 times better than atof()!"
    }
    if { $cpu_strtod < 1.5 * $cpu_Strtod } {
      puts "Error: Strtod() is expected to be at least 2 times better than strtod()!"
    }
  }
}

puts "1M random values, 10 significant digits, in range (-1e9, 1e9)"
CheckAtof 1000000 10 -1e9 1e9

puts "1M random values, 10 significant digits, in range (-1e305, 1e305)"
CheckAtof 1000000 10 -1e305 1e305

puts "1M random values, 16 significant digits, in range (-1e9, 1e9)"
CheckAtof 1000000 16 -1e9 1e9

puts "1M random values, 18 significant digits, in range (-1e305, 1e305)"
CheckAtof 1000000 16 -1e305 1e305

# Disarm FPE signals - otherwise they will be raised if signaling NAN appears
dsetsignal 0

puts "Special values + 1M values defined by random binary data, 10 digits"
CheckAtof 1000000 10 0 0

puts "Special values + 1M values defined by random binary data, 16 digits"
CheckAtof 1000000 16 0 0