StatProfilerHTML.jl report
Generated on tor 10 okt 2019 11:38:33
File source code
Line Exclusive Inclusive Code
1 # This file is a part of Julia, but is derived from
2 # https://github.com/google/double-conversion which has the following license
3 #
4 # Copyright 2006-2014, the V8 project authors. All rights reserved.
5 # Redistribution and use in source and binary forms, with or without
6 # modification, are permitted provided that the following conditions are
7 # met:
8 #
9 # * Redistributions of source code must retain the above copyright
10 # notice, this list of conditions and the following disclaimer.
11 # * Redistributions in binary form must reproduce the above
12 # copyright notice, this list of conditions and the following
13 # disclaimer in the documentation and/or other materials provided
14 # with the distribution.
15 # * Neither the name of Google Inc. nor the names of its
16 # contributors may be used to endorse or promote products derived
17 # from this software without specific prior written permission.
18 #
19 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30
31 const kMinExp = -60
32 const kMaxExp = -32
33
34
1 (2.38%) samples spent in roundweed
1 (100.00%) (ex.), 1 (100.00%) (incl.) when called from digitgen line 98
function roundweed(buffer,len,rest,tk,unit,kappa,too_high::UInt64,unsafe_interval::UInt64)
35 small = too_high - unit
36 big = too_high + unit
37 while rest < small &&
38 unsafe_interval - rest >= tk &&
39 (rest + tk < small ||
40 small - rest >= rest + tk - small)
41 buffer[len-1] -= 1
42 rest += tk
43 end
44 if rest < big &&
45 unsafe_interval - rest >= tk &&
46 (rest + tk < big ||
47 big - rest > rest + tk - big)
48 return false, kappa
49 end
50 1 (2.38%) 1 (2.38%) return (2 * unit <= rest) && (rest <= unsafe_interval - 4 * unit), kappa
51 end
52
53 const SmallPowersOfTen = [
54 0, 1, 10, 100, 1000, 10000, 100000,
55 1000000, 10000000, 100000000, 1000000000]
56
57 function bigpowten(n,n_bits)
58 guess = ((n_bits + 1) * 1233) >> 12
59 guess += 1
60 i = SmallPowersOfTen[guess+1]
61 return n < i ? (SmallPowersOfTen[guess], guess-1) : (i,guess)
62 end
63
64
8 (19.05%) samples spent in digitgen
1 (100.00%) (ex.), 8 (100.00%) (incl.) when called from fastshortest line 114
function digitgen(low,w,high,buffer)
65 unit::UInt64 = 1
66 one = Float(unit << -w.e, w.e)
67 too_high = Float(high.s+unit,high.e)
68 unsafe_interval = too_high - Float(low.s-unit,low.e)
69 integrals = too_high.s >> -one.e
70 fractionals = too_high.s & (one.s-1)
71 divisor, kappa = bigpowten(integrals, 64 + one.e)
72 len = 1
73 rest = UInt64(0)
74 while kappa > 0
75 2 (4.76%)
2 (100.00%) samples spent calling div
digit = div(integrals,divisor)
76 buffer[len] = 0x30 + digit
77 len += 1
78 integrals %= divisor
79 kappa -= 1
80 rest = (UInt64(integrals) << -one.e) + fractionals
81 if rest < unsafe_interval.s
82 r, kappa = roundweed(buffer, len, rest, UInt64(divisor) << -one.e,
83 unit,kappa,(too_high - w).s,unsafe_interval.s)
84 return r, kappa, len
85 end
86 divisor = div(divisor,10)
87 end
88 while true
89 fractionals *= 10
90 unit *= 10
91 unsafe_interval = Float(unsafe_interval.s*10,unsafe_interval.e)
92 1 (2.38%)
1 (100.00%) samples spent calling >>
digit = fractionals >> -one.e
93 1 (2.38%)
1 (100.00%) samples spent calling +
buffer[len] = 0x30 + digit
94 len += 1
95 fractionals &= one.s - 1
96 kappa -= 1
97 1 (2.38%)
1 (100.00%) samples spent calling <
if fractionals < unsafe_interval.s
98 2 (4.76%)
1 (50.00%) samples spent calling *
1 (50.00%) samples spent calling roundweed
r, kappa = roundweed(buffer,len,fractionals,one.s,
99 unit,kappa,(too_high - w).s*unit,unsafe_interval.s)
100 1 (2.38%) 1 (2.38%) return r, kappa, len
101 end
102 end
103 end
104
105
11 (26.19%) samples spent in fastshortest
1 (100.00%) (ex.), 11 (100.00%) (incl.) when called from grisu line 71
function fastshortest(v, buffer = Vector{UInt8}(undef, 17))
106 f = normalize(Float64(v))
107 1 (2.38%)
1 (100.00%) samples spent calling normalizedbound
bound_minus, bound_plus = normalizedbound(v)
108 ten_mk_min_exp = kMinExp - (f.e + FloatSignificandSize)
109 ten_mk_max_exp = kMaxExp - (f.e + FloatSignificandSize)
110 1 (2.38%)
1 (100.00%) samples spent calling binexp_cache
cp = binexp_cache(ten_mk_min_exp,ten_mk_max_exp)
111 scaled_w = f * cp
112 scaled_bound_minus = bound_minus * cp
113 scaled_bound_plus = bound_plus * cp
114 8 (19.05%)
8 (100.00%) samples spent calling digitgen
r, kappa, len = digitgen(scaled_bound_minus,scaled_w,
115 scaled_bound_plus,buffer)
116 decimal_exponent = -cp.de + kappa
117 1 (2.38%) 1 (2.38%) return r, len, decimal_exponent+len-1
118 end