Skip to content

Commit

Permalink
Fix printf performance regression.
Browse files Browse the repository at this point in the history
This is a temporary fix: we should probably make these into
intrinsics so that there is no performance loss when constants
are used like this.
  • Loading branch information
StefanKarpinski committed Jan 30, 2012
1 parent 8a05f85 commit 8f752a9
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 17 deletions.
2 changes: 1 addition & 1 deletion j/int.j
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ typemin(::Type{Int16 }) = int16(-32768)
typemax(::Type{Int16 }) = int16(32767)
typemin(::Type{Uint16}) = uint16(0)
typemax(::Type{Uint16}) = uint16(65535)
@eval typemin(::Type{Int32 }) = $int32(-2147483647-1)
typemin(::Type{Int32 }) = int32(-2147483648)
typemax(::Type{Int32 }) = int32(2147483647)
typemin(::Type{Uint32}) = uint32(0)
typemax(::Type{Uint32}) = uint32(4294967295)
Expand Down
20 changes: 10 additions & 10 deletions j/printf.j
Original file line number Diff line number Diff line change
Expand Up @@ -526,8 +526,8 @@ function _jl_decode_dec(x::Unsigned)
@handle_zero
_jl_point[1] = i = ndigits0z(x)
while i > 0
_jl_digits[i] = '0'+mod(x,10)
x = div(x,10)
_jl_digits[i] = '0'+mod(x,uint(10))
x = div(x,uint(10))
i -= 1
end
end
Expand Down Expand Up @@ -646,8 +646,8 @@ function _jl_ini_dec(x::Unsigned, n::Int)
if k <= n
_jl_point[1] = k
for i = k:-1:1
_jl_digits[i] = '0'+mod(x,10)
x = div(x,10)
_jl_digits[i] = '0'+mod(x,uint(10))
x = div(x,uint(10))
end
for i = k+1:n
_jl_digits[i] = '0'
Expand All @@ -665,8 +665,8 @@ function _jl_ini_dec(x::Unsigned, n::Int)
_jl_point[1] = k
x = div(x,p)
for i = n:-1:1
_jl_digits[i] = '0'+mod(x,10)
x = div(x,10)
_jl_digits[i] = '0'+mod(x,uint(10))
x = div(x,uint(10))
end
end
end
Expand Down Expand Up @@ -704,8 +704,8 @@ function _jl_sig_dec(x::Unsigned, n::Int)
if k <= n
_jl_point[1] = k
for i = k:-1:1
_jl_digits[i] = '0'+mod(x,10)
x = div(x,10)
_jl_digits[i] = '0'+mod(x,uint(10))
x = div(x,uint(10))
end
while _jl_digits[k] == '0'
k -= 1
Expand All @@ -724,8 +724,8 @@ function _jl_sig_dec(x::Unsigned, n::Int)
_jl_point[1] = k
x = div(x,p)
for i = n:-1:1
_jl_digits[i] = '0'+mod(x,10)
x = div(x,10)
_jl_digits[i] = '0'+mod(x,uint(10))
x = div(x,uint(10))
end
while _jl_digits[n] == '0'
n -= 1
Expand Down
9 changes: 3 additions & 6 deletions test/perf/perf.j
Original file line number Diff line number Diff line change
Expand Up @@ -117,13 +117,10 @@ end
function printfd(n)
f = open("/dev/null","w")
for i = 1:n
fprintf(f, f"%d %d\n", i, i)
# fprintf(f, f"%d %d\n", i, i)
# f"%d %d\n"(f,i,i)
@printf "%d %d\n" f i i
end
# with_output_stream(f, @thunk begin
# for i = 1:n
# @printf "%d %d\n" f i i
# end
# end)
close(f)
end

Expand Down

0 comments on commit 8f752a9

Please sign in to comment.