diff --git a/julia/dowhile.jl b/julia/dowhile.jl index 6722f256ac7ee54ba7eea617af76eda2c35ea248..40c602a99eeaa251bfbfc21b58d0a6f0f58aa673 100644 --- a/julia/dowhile.jl +++ b/julia/dowhile.jl @@ -2,14 +2,12 @@ macro doWhile(block, cond) println("__source__ ", __source__) println("cond ", cond) println("block ", block) - res = quote - while true - $(esc(block)) - if $(esc(cond)) - break - end + res = esc(quote + $block + while $cond + $block end - end - println(res) # Should not print any lines referencing dowhile.jl + end) + println(res.args) # Should not print any lines referencing dowhile.jl res end diff --git a/julia/run.jl b/julia/run.jl index 7fab59aa8cfe30243b49bbdfff687f8ea034eef8..2220d805f81666a9e2cfbbba9c2e55fb294088e0 100644 --- a/julia/run.jl +++ b/julia/run.jl @@ -41,6 +41,6 @@ function testDoWhile() @assert a < 18 a += 1 println(a) - end a==100 + end a < 100 end testDoWhile() diff --git a/profiling/julia-1.0.4/share/julia/base/gcutils.jl.19966.cov b/profiling/julia-1.0.4/share/julia/base/gcutils.jl.19966.cov new file mode 100644 index 0000000000000000000000000000000000000000..f66b49d61c91e78efb6721c5b205ba848cda61bd --- /dev/null +++ b/profiling/julia-1.0.4/share/julia/base/gcutils.jl.19966.cov @@ -0,0 +1,94 @@ + - # This file is a part of Julia. License is MIT: https://julialang.org/license + - + - ==(w::WeakRef, v::WeakRef) = isequal(w.value, v.value) + - ==(w::WeakRef, v) = isequal(w.value, v) + - ==(w, v::WeakRef) = isequal(w, v.value) + - + - """ + - finalizer(f, x) + - + - Register a function `f(x)` to be called when there are no program-accessible references to + - `x`, and return `x`. The type of `x` must be a `mutable struct`, otherwise the behavior of + - this function is unpredictable. + - """ + - function finalizer(@nospecialize(f), @nospecialize(o)) + - if isimmutable(o) + - error("objects of type ", typeof(o), " cannot be finalized") + - end + - ccall(:jl_gc_add_finalizer_th, Cvoid, (Ptr{Cvoid}, Any, Any), + - Core.getptls(), o, f) + - return o + - end + - + - function finalizer(f::Ptr{Cvoid}, o::T) where T + - @_inline_meta + - if isimmutable(T) + - error("objects of type ", T, " cannot be finalized") + - end + - ccall(:jl_gc_add_ptr_finalizer, Cvoid, (Ptr{Cvoid}, Any, Ptr{Cvoid}), + - Core.getptls(), o, f) + - return o + - end + - + - """ + - finalize(x) + - + - Immediately run finalizers registered for object `x`. + - """ + - finalize(@nospecialize(o)) = ccall(:jl_finalize_th, Cvoid, (Ptr{Cvoid}, Any,), + - Core.getptls(), o) + - + - """ + - Base.GC + - + - Module with garbage collection utilities. + - """ + - module GC + - + - """ + - GC.gc() + - + - Perform garbage collection. + - + - !!! warning + - Excessive use will likely lead to poor performance. + - """ + - gc(full::Bool=true) = ccall(:jl_gc_collect, Cvoid, (Int32,), full) + - + - """ + - GC.enable(on::Bool) + - + - Control whether garbage collection is enabled using a boolean argument (`true` for enabled, + - `false` for disabled). Return previous GC state. + - + - !!! warning + - Disabling garbage collection should be used only with caution, as it can cause memory + - use to grow without bound. + - """ + - enable(on::Bool) = ccall(:jl_gc_enable, Int32, (Int32,), on) != 0 + - + - """ + - GC.@preserve x1 x2 ... xn expr + - + - Temporarily protect the given objects from being garbage collected, even if they would + - otherwise be unreferenced. + - + - The last argument is the expression during which the object(s) will be preserved. + - The previous arguments are the objects to preserve. + - """ + - macro preserve(args...) + - syms = args[1:end-1] + - for x in syms + - isa(x, Symbol) || error("Preserved variable must be a symbol") + - end + - s, r = gensym(), gensym() + - esc(quote + 2824 $s = $(Expr(:gc_preserve_begin, syms...)) + 2824 $r = $(args[end]) + 2824 $(Expr(:gc_preserve_end, s)) + - $r + - end) + - end + - + - end # module GC + - diff --git a/profiling/julia-1.0.4/share/julia/base/gcutils.jl.20032.cov b/profiling/julia-1.0.4/share/julia/base/gcutils.jl.20032.cov new file mode 100644 index 0000000000000000000000000000000000000000..ab2eaf250f524d373dd5620dc0426553c166204b --- /dev/null +++ b/profiling/julia-1.0.4/share/julia/base/gcutils.jl.20032.cov @@ -0,0 +1,94 @@ + - # This file is a part of Julia. License is MIT: https://julialang.org/license + - + - ==(w::WeakRef, v::WeakRef) = isequal(w.value, v.value) + - ==(w::WeakRef, v) = isequal(w.value, v) + - ==(w, v::WeakRef) = isequal(w, v.value) + - + - """ + - finalizer(f, x) + - + - Register a function `f(x)` to be called when there are no program-accessible references to + - `x`, and return `x`. The type of `x` must be a `mutable struct`, otherwise the behavior of + - this function is unpredictable. + - """ + - function finalizer(@nospecialize(f), @nospecialize(o)) + - if isimmutable(o) + - error("objects of type ", typeof(o), " cannot be finalized") + - end + - ccall(:jl_gc_add_finalizer_th, Cvoid, (Ptr{Cvoid}, Any, Any), + - Core.getptls(), o, f) + - return o + - end + - + - function finalizer(f::Ptr{Cvoid}, o::T) where T + - @_inline_meta + - if isimmutable(T) + - error("objects of type ", T, " cannot be finalized") + - end + - ccall(:jl_gc_add_ptr_finalizer, Cvoid, (Ptr{Cvoid}, Any, Ptr{Cvoid}), + - Core.getptls(), o, f) + - return o + - end + - + - """ + - finalize(x) + - + - Immediately run finalizers registered for object `x`. + - """ + - finalize(@nospecialize(o)) = ccall(:jl_finalize_th, Cvoid, (Ptr{Cvoid}, Any,), + - Core.getptls(), o) + - + - """ + - Base.GC + - + - Module with garbage collection utilities. + - """ + - module GC + - + - """ + - GC.gc() + - + - Perform garbage collection. + - + - !!! warning + - Excessive use will likely lead to poor performance. + - """ + - gc(full::Bool=true) = ccall(:jl_gc_collect, Cvoid, (Int32,), full) + - + - """ + - GC.enable(on::Bool) + - + - Control whether garbage collection is enabled using a boolean argument (`true` for enabled, + - `false` for disabled). Return previous GC state. + - + - !!! warning + - Disabling garbage collection should be used only with caution, as it can cause memory + - use to grow without bound. + - """ + - enable(on::Bool) = ccall(:jl_gc_enable, Int32, (Int32,), on) != 0 + - + - """ + - GC.@preserve x1 x2 ... xn expr + - + - Temporarily protect the given objects from being garbage collected, even if they would + - otherwise be unreferenced. + - + - The last argument is the expression during which the object(s) will be preserved. + - The previous arguments are the objects to preserve. + - """ + - macro preserve(args...) + - syms = args[1:end-1] + - for x in syms + - isa(x, Symbol) || error("Preserved variable must be a symbol") + - end + - s, r = gensym(), gensym() + - esc(quote + 2 $s = $(Expr(:gc_preserve_begin, syms...)) + 2 $r = $(args[end]) + 2 $(Expr(:gc_preserve_end, s)) + - $r + - end) + - end + - + - end # module GC + - diff --git a/profiling/julia-1.0.4/share/julia/base/logging.jl.19966.cov b/profiling/julia-1.0.4/share/julia/base/logging.jl.19966.cov new file mode 100644 index 0000000000000000000000000000000000000000..a84ba410bd2ad5afdae99930b7b7f11cf7550dc3 --- /dev/null +++ b/profiling/julia-1.0.4/share/julia/base/logging.jl.19966.cov @@ -0,0 +1,551 @@ + - # This file is a part of Julia. License is MIT: https://julialang.org/license + - + - module CoreLogging + - + - import Base: isless, +, -, convert, show + - + - export + - AbstractLogger, + - LogLevel, + - NullLogger, + - @debug, + - @info, + - @warn, + - @error, + - @logmsg, + - with_logger, + - current_logger, + - global_logger, + - disable_logging, + - SimpleLogger + - + - #------------------------------------------------------------------------------- + - # The AbstractLogger interface + - """ + - A logger controls how log records are filtered and dispatched. When a log + - record is generated, the logger is the first piece of user configurable code + - which gets to inspect the record and decide what to do with it. + - """ + - abstract type AbstractLogger ; end + - + - """ + - handle_message(logger, level, message, _module, group, id, file, line; key1=val1, ...) + - + - Log a message to `logger` at `level`. The logical location at which the + - message was generated is given by module `_module` and `group`; the source + - location by `file` and `line`. `id` is an arbitrary unique `Symbol` to be used + - as a key to identify the log statement when filtering. + - """ + - function handle_message end + - + - """ + - shouldlog(logger, level, _module, group, id) + - + - Return true when `logger` accepts a message at `level`, generated for + - `_module`, `group` and with unique log identifier `id`. + - """ + - function shouldlog end + - + - """ + - min_enabled_level(logger) + - + - Return the maximum disabled level for `logger` for early filtering. That is, + - the log level below or equal to which all messages are filtered. + - """ + - function min_enabled_level end + - + - """ + - catch_exceptions(logger) + - + - Return true if the logger should catch exceptions which happen during log + - record construction. By default, messages are caught + - + - By default all exceptions are caught to prevent log message generation from + - crashing the program. This lets users confidently toggle little-used + - functionality - such as debug logging - in a production system. + - + - If you want to use logging as an audit trail you should disable this for your + - logger type. + - """ + - catch_exceptions(logger) = true + - + - + - # The logger equivalent of /dev/null, for when a placeholder is needed + - """ + - NullLogger() + - + - Logger which disables all messages and produces no output - the logger + - equivalent of /dev/null. + - """ + - struct NullLogger <: AbstractLogger; end + - + - min_enabled_level(::NullLogger) = AboveMaxLevel + - shouldlog(::NullLogger, args...) = false + - handle_message(::NullLogger, args...; kwargs...) = + - error("Null logger handle_message() should not be called") + - + - + - #------------------------------------------------------------------------------- + - # Standard log levels + - """ + - LogLevel(level) + - + - Severity/verbosity of a log record. + - + - The log level provides a key against which potential log records may be + - filtered, before any other work is done to construct the log record data + - structure itself. + - """ + - struct LogLevel + - level::Int32 + - end + - + - LogLevel(level::LogLevel) = level + - + - isless(a::LogLevel, b::LogLevel) = isless(a.level, b.level) + - +(level::LogLevel, inc::Integer) = LogLevel(level.level+inc) + - -(level::LogLevel, inc::Integer) = LogLevel(level.level-inc) + - convert(::Type{LogLevel}, level::Integer) = LogLevel(level) + - + - const BelowMinLevel = LogLevel(-1000001) + - const Debug = LogLevel( -1000) + - const Info = LogLevel( 0) + - const Warn = LogLevel( 1000) + - const Error = LogLevel( 2000) + - const AboveMaxLevel = LogLevel( 1000001) + - + - function show(io::IO, level::LogLevel) + - if level == BelowMinLevel print(io, "BelowMinLevel") + - elseif level == Debug print(io, "Debug") + - elseif level == Info print(io, "Info") + - elseif level == Warn print(io, "Warn") + - elseif level == Error print(io, "Error") + - elseif level == AboveMaxLevel print(io, "AboveMaxLevel") + - else print(io, "LogLevel($(level.level))") + - end + - end + - + - + - #------------------------------------------------------------------------------- + - # Logging macros + - + - _logmsg_docs = """ + - @debug message [key=value | value ...] + - @info message [key=value | value ...] + - @warn message [key=value | value ...] + - @error message [key=value | value ...] + - + - @logmsg level message [key=value | value ...] + - + - Create a log record with an informational `message`. For convenience, four + - logging macros `@debug`, `@info`, `@warn` and `@error` are defined which log at + - the standard severity levels `Debug`, `Info`, `Warn` and `Error`. `@logmsg` + - allows `level` to be set programmatically to any `LogLevel` or custom log level + - types. + - + - `message` should be an expression which evaluates to a string which is a human + - readable description of the log event. By convention, this string will be + - formatted as markdown when presented. + - + - The optional list of `key=value` pairs supports arbitrary user defined + - metadata which will be passed through to the logging backend as part of the + - log record. If only a `value` expression is supplied, a key representing the + - expression will be generated using `Symbol`. For example, `x` becomes `x=x`, + - and `foo(10)` becomes `Symbol("foo(10)")=foo(10)`. For splatting a list of + - key value pairs, use the normal splatting syntax, `@info "blah" kws...`. + - + - There are some keys which allow automatically generated log data to be + - overridden: + - + - * `_module=mod` can be used to specify a different originating module from + - the source location of the message. + - * `_group=symbol` can be used to override the message group (this is + - normally derived from the base name of the source file). + - * `_id=symbol` can be used to override the automatically generated unique + - message identifier. This is useful if you need to very closely associate + - messages generated on different source lines. + - * `_file=string` and `_line=integer` can be used to override the apparent + - source location of a log message. + - + - There's also some key value pairs which have conventional meaning: + - + - * `maxlog=integer` should be used as a hint to the backend that the message + - should be displayed no more than `maxlog` times. + - * `exception=ex` should be used to transport an exception with a log message, + - often used with `@error`. An associated backtrace `bt` may be attached + - using the tuple `exception=(ex,bt)`. + - + - # Examples + - + - ``` + - @debug "Verbose debugging information. Invisible by default" + - @info "An informational message" + - @warn "Something was odd. You should pay attention" + - @error "A non fatal error occurred" + - + - x = 10 + - @info "Some variables attached to the message" x a=42.0 + - + - @debug begin + - sA = sum(A) + - "sum(A) = \$sA is an expensive operation, evaluated only when `shouldlog` returns true" + - end + - + - for i=1:10000 + - @info "With the default backend, you will only see (i = \$i) ten times" maxlog=10 + - @debug "Algorithm1" i progress=i/10000 + - end + - ``` + - """ + - + - # Get (module,filepath,line) for the location of the caller of a macro. + - # Designed to be used from within the body of a macro. + - macro _sourceinfo() + - esc(quote + - (__module__, + - __source__.file === nothing ? "?" : String(__source__.file), + - __source__.line) + - end) + - end + - + - macro logmsg(level, exs...) logmsg_code((@_sourceinfo)..., esc(level), exs...) end + - macro debug(exs...) logmsg_code((@_sourceinfo)..., :Debug, exs...) end + - macro info(exs...) logmsg_code((@_sourceinfo)..., :Info, exs...) end + - macro warn(exs...) logmsg_code((@_sourceinfo)..., :Warn, exs...) end + - macro error(exs...) logmsg_code((@_sourceinfo)..., :Error, exs...) end + - + - # Logging macros share documentation + - @eval @doc $_logmsg_docs :(@logmsg) + - @eval @doc $_logmsg_docs :(@debug) + - @eval @doc $_logmsg_docs :(@info) + - @eval @doc $_logmsg_docs :(@warn) + - @eval @doc $_logmsg_docs :(@error) + - + - _log_record_ids = Set{Symbol}() + - # Generate a unique, stable, short, somewhat human readable identifier for a + - # logging *statement*. The idea here is to have a key against which log events + - # can be filtered and otherwise manipulated. The key should uniquely identify + - # the source location in the originating module, but ideally should be stable + - # across versions of the originating module, provided the log generating + - # statement itself doesn't change. + - function log_record_id(_module, level, message, log_kws) + - modname = _module === nothing ? "" : join(fullname(_module), "_") + - # Use an arbitriraly chosen eight hex digits here. TODO: Figure out how to + - # make the id exactly the same on 32 and 64 bit systems. + - h = UInt32(hash(string(modname, level, message, log_kws)) & 0xFFFFFFFF) + - while true + - id = Symbol(modname, '_', string(h, base = 16, pad = 8)) + - # _log_record_ids is a registry of log record ids for use during + - # compilation, to ensure uniqueness of ids. Note that this state will + - # only persist during module compilation so it will be empty when a + - # precompiled module is loaded. + - if !(id in _log_record_ids) + - push!(_log_record_ids, id) + - return id + - end + - h += 1 + - end + - end + - + - # Generate code for logging macros + - function logmsg_code(_module, file, line, level, message, exs...) + - id = Expr(:quote, log_record_id(_module, level, message, exs)) + - group = nothing + - kwargs = Any[] + - for ex in exs + - if ex isa Expr && ex.head === :(=) && ex.args[1] isa Symbol + - k,v = ex.args + - if !(k isa Symbol) + - throw(ArgumentError("Expected symbol for key in key value pair `$ex`")) + - end + - k = ex.args[1] + - # Recognize several special keyword arguments + - if k == :_id + - # id may be overridden if you really want several log + - # statements to share the same id (eg, several pertaining to + - # the same progress step). In those cases it may be wise to + - # manually call log_record_id to get a unique id in the same + - # format. + - id = esc(v) + - elseif k == :_module + - _module = esc(v) + - elseif k == :_line + - line = esc(v) + - elseif k == :_file + - file = esc(v) + - elseif k == :_group + - group = esc(v) + - else + - # Copy across key value pairs for structured log records + - push!(kwargs, Expr(:kw, k, esc(v))) + - end + - elseif ex isa Expr && ex.head === :... + - # Keyword splatting + - push!(kwargs, esc(ex)) + - else + - # Positional arguments - will be converted to key value pairs + - # automatically. + - push!(kwargs, Expr(:kw, Symbol(ex), esc(ex))) + - end + - end + - + - if group == nothing + - group = if isdefined(Base, :basename) && isa(file, String) + - # precompute if we can + - QuoteNode(splitext(basename(file))[1]) + - else + - # memoized run-time execution + - ref = Ref{Symbol}() + - :(isassigned($ref) ? $ref[] + - : $ref[] = Symbol(splitext(basename(something($file, "")))[1])) + - end + - end + - + - quote + 0 level = $level + 0 std_level = convert(LogLevel, level) + 0 if std_level >= getindex(_min_enabled_level) + - group = $group + - _module = $_module + 0 logger = current_logger_for_env(std_level, group, _module) + 0 if !(logger === nothing) + - id = $id + - # Second chance at an early bail-out (before computing the message), + - # based on arbitrary logger-specific logic. + 0 if shouldlog(logger, level, _module, group, id) + - file = $file + - line = $line + 0 try + - msg = $(esc(message)) + 0 handle_message(logger, level, msg, _module, group, id, file, line; $(kwargs...)) + - catch err + 0 logging_error(logger, level, _module, group, id, file, line, err) + - end + - end + - end + - end + 0 nothing + - end + - end + - + - # Report an error in log message creation (or in the logger itself). + - @noinline function logging_error(logger, level, _module, group, id, + - filepath, line, @nospecialize(err)) + - if !catch_exceptions(logger) + - rethrow(err) + - end + - try + - msg = "Exception while generating log record in module $_module at $filepath:$line" + - handle_message(logger, Error, msg, _module, :logevent_error, id, filepath, line; exception=(err,catch_backtrace())) + - catch err2 + - try + - # Give up and write to stderr, in three independent calls to + - # increase the odds of it getting through. + - print(stderr, "Exception handling log message: ") + - println(stderr, err) + - println(stderr, " module=$_module file=$filepath line=$line") + - println(stderr, " Second exception: ", err2) + - catch + - end + - end + - nothing + - end + - + - # Log a message. Called from the julia C code; kwargs is in the format + - # Any[key1,val1, ...] for simplicity in construction on the C side. + - function logmsg_shim(level, message, _module, group, id, file, line, kwargs) + - real_kws = Any[(kwargs[i],kwargs[i+1]) for i in 1:2:length(kwargs)] + - @logmsg(convert(LogLevel, level), message, + - _module=_module, _id=id, _group=group, + - _file=String(file), _line=line, real_kws...) + - end + - + - # Global log limiting mechanism for super fast but inflexible global log + - # limiting. + - const _min_enabled_level = Ref(Debug) + - + - # LogState - a concretely typed cache of data extracted from the logger, plus + - # the logger itself. + - struct LogState + - min_enabled_level::LogLevel + - logger::AbstractLogger + - end + - + - LogState(logger) = LogState(LogLevel(min_enabled_level(logger)), logger) + - + - function current_logstate() + - logstate = current_task().logstate + - return (logstate !== nothing ? logstate : _global_logstate)::LogState + - end + - + - # helper function to get the current logger, if enabled for the specified message type + - @noinline function current_logger_for_env(std_level::LogLevel, group, _module) + - logstate = current_logstate() + - if std_level >= logstate.min_enabled_level || env_override_minlevel(group, _module) + - return logstate.logger + - end + - return nothing + - end + - + - function with_logstate(f::Function, logstate) + - t = current_task() + - old = t.logstate + - try + - t.logstate = logstate + - f() + - finally + - t.logstate = old + - end + - end + - + - + - #------------------------------------------------------------------------------- + - # Control of the current logger and early log filtering + - + - """ + - disable_logging(level) + - + - Disable all log messages at log levels equal to or less than `level`. This is + - a *global* setting, intended to make debug logging extremely cheap when + - disabled. + - """ + - function disable_logging(level::LogLevel) + - _min_enabled_level[] = level + 1 + - end + - + - let _debug_groups = Symbol[], + - _debug_str::String = "" + - global function env_override_minlevel(group, _module) + - debug = get(ENV, "JULIA_DEBUG", "") + - if !(debug === _debug_str) + - _debug_str = debug + - empty!(_debug_groups) + - for g in split(debug, ',') + - isempty(g) && continue + - if g == "all" + - empty!(_debug_groups) + - push!(_debug_groups, :all) + - break + - end + - push!(_debug_groups, Symbol(g)) + - end + - end + - if isempty(_debug_groups) + - return false + - end + - if _debug_groups[1] == :all + - return true + - end + - if isa(group, Symbol) && group in _debug_groups + - return true + - end + - if isa(_module, Module) + - if nameof(_module) in _debug_groups + - return true + - end + - if nameof(Base.moduleroot(_module)) in _debug_groups + - return true + - end + - end + - return false + - end + - end + - + - + - """ + - global_logger() + - + - Return the global logger, used to receive messages when no specific logger + - exists for the current task. + - + - global_logger(logger) + - + - Set the global logger to `logger`, and return the previous global logger. + - """ + - global_logger() = _global_logstate.logger + - + - function global_logger(logger::AbstractLogger) + - prev = _global_logstate.logger + - global _global_logstate = LogState(logger) + - prev + - end + - + - """ + - with_logger(function, logger) + - + - Execute `function`, directing all log messages to `logger`. + - + - # Example + - + - ```julia + - function test(x) + - @info "x = \$x" + - end + - + - with_logger(logger) do + - test(1) + - test([1,2]) + - end + - ``` + - """ + - with_logger(f::Function, logger::AbstractLogger) = with_logstate(f, LogState(logger)) + - + - """ + - current_logger() + - + - Return the logger for the current task, or the global logger if none is + - attached to the task. + - """ + - current_logger() = current_logstate().logger + - + - + - #------------------------------------------------------------------------------- + - # SimpleLogger + - """ + - SimpleLogger(stream=stderr, min_level=Info) + - + - Simplistic logger for logging all messages with level greater than or equal to + - `min_level` to `stream`. + - """ + - struct SimpleLogger <: AbstractLogger + - stream::IO + - min_level::LogLevel + - message_limits::Dict{Any,Int} + - end + - SimpleLogger(stream::IO=stderr, level=Info) = SimpleLogger(stream, level, Dict{Any,Int}()) + - + - shouldlog(logger::SimpleLogger, level, _module, group, id) = + - get(logger.message_limits, id, 1) > 0 + - + - min_enabled_level(logger::SimpleLogger) = logger.min_level + - + - catch_exceptions(logger::SimpleLogger) = false + - + - function handle_message(logger::SimpleLogger, level, message, _module, group, id, + - filepath, line; maxlog=nothing, kwargs...) + - if maxlog != nothing && maxlog isa Integer + - remaining = get!(logger.message_limits, id, maxlog) + - logger.message_limits[id] = remaining - 1 + - remaining > 0 || return + - end + - buf = IOBuffer() + - iob = IOContext(buf, logger.stream) + - levelstr = level == Warn ? "Warning" : string(level) + - msglines = split(chomp(string(message)), '\n') + - println(iob, "┌ ", levelstr, ": ", msglines[1]) + - for i in 2:length(msglines) + - println(iob, "│ ", msglines[i]) + - end + - for (key, val) in kwargs + - println(iob, "│ ", key, " = ", val) + - end + - println(iob, "└ @ ", something(_module, "nothing"), " ", + - something(filepath, "nothing"), ":", something(line, "nothing")) + - write(logger.stream, take!(buf)) + - nothing + - end + - + - _global_logstate = LogState(SimpleLogger(Core.stderr, CoreLogging.Info)) + - + - end # CoreLogging + - diff --git a/profiling/julia-1.0.4/share/julia/base/printf.jl.19966.cov b/profiling/julia-1.0.4/share/julia/base/printf.jl.19966.cov new file mode 100644 index 0000000000000000000000000000000000000000..0dc93f2279e47621d7719e241e5349c349f0c546 --- /dev/null +++ b/profiling/julia-1.0.4/share/julia/base/printf.jl.19966.cov @@ -0,0 +1,1262 @@ + - # This file is a part of Julia. License is MIT: https://julialang.org/license + - + - module Printf + - using .Base.Grisu + - using .Base.GMP + - + - ### printf formatter generation ### + - const SmallFloatingPoint = Union{Float64,Float32,Float16} + - const SmallNumber = Union{SmallFloatingPoint,Base.BitInteger} + - + - function gen(s::AbstractString) + - args = [] + - blk = Expr(:block, :(local neg, pt, len, exp, do_out, args)) + - for x in parse(s) + - if isa(x,AbstractString) + - push!(blk.args, :(print(out, $(length(x)==1 ? x[1] : x)))) + - else + - c = lowercase(x[end]) + - f = c=='f' ? gen_f : + - c=='e' ? gen_e : + - c=='a' ? gen_a : + - c=='g' ? gen_g : + - c=='c' ? gen_c : + - c=='s' ? gen_s : + - c=='p' ? gen_p : + - gen_d + - arg, ex = f(x...) + - push!(args, arg) + - push!(blk.args, ex) + - end + - end + - push!(blk.args, :nothing) + - return args, blk + - end + - + - ### printf format string parsing ### + - + - function parse(s::AbstractString) + - # parse format string into strings and format tuples + - list = [] + - a = Iterators.Stateful(pairs(s)) + - lastparse = firstindex(s) + - lastidx = 0 # invariant: lastidx == prevind(s, idx) + - for (idx, c) in a + - if c == '%' + - lastparse > lastidx || push!(list, s[lastparse:lastidx]) + - flags, width, precision, conversion = parse1!(s, a) + - '\'' in flags && error("printf format flag ' not yet supported") + - conversion == 'n' && error("printf feature %n not supported") + - push!(list, conversion == '%' ? "%" : (flags,width,precision,conversion)) + - lastparse = isempty(a) ? lastindex(s)+1 : Base.peek(a)[1] + - end + - lastidx = idx + - end + - lastparse > lastindex(s) || push!(list, s[lastparse:end]) + - # coalesce adjacent strings + - i = j = 1 + - while i < length(list) + - if isa(list[i],AbstractString) + - for outer j = i+1:length(list) + - if !isa(list[j],AbstractString) + - j -= 1 + - break + - end + - list[i] *= list[j] + - end + - deleteat!(list,i+1:j) + - end + - i += 1 + - end + - return list + - end + - + - ## parse a single printf specifier ## + - + - # printf specifiers: + - # % # start + - # (\d+\$)? # arg (not supported) + - # [\-\+#0' ]* # flags + - # (\d+)? # width + - # (\.\d*)? # precision + - # (h|hh|l|ll|L|j|t|z|q)? # modifier (ignored) + - # [diouxXeEfFgGaAcCsSp%] # conversion + - + - pop_or_die!(s, a) = !isempty(a) ? popfirst!(a) : + - throw(ArgumentError("invalid printf format string: $(repr(s))")) + - + - function parse1!(s, a) + - width = 0 + - precision = -1 + - k, c = pop_or_die!(s, a) + - j = k + - # handle %% + - if c == '%' + - return "", width, precision, c + - end + - # parse flags + - while c in "#0- + '" + - k, c = pop_or_die!(s, a) + - end + - flags = String(s[j:k-1]) # All flags are 1 byte + - # parse width + - while '0' <= c <= '9' + - width = 10*width + c-'0' + - _, c = pop_or_die!(s, a) + - end + - # parse precision + - if c == '.' + - _, c = pop_or_die!(s, a) + - if '0' <= c <= '9' + - precision = 0 + - while '0' <= c <= '9' + - precision = 10*precision + c-'0' + - _, c = pop_or_die!(s, a) + - end + - end + - end + - # parse length modifer (ignored) + - if c == 'h' || c == 'l' + - prev = c + - _, c = pop_or_die!(s, a) + - if c == prev + - _, c = pop_or_die!(s, a) + - end + - elseif c in "Ljqtz" + - _, c = pop_or_die!(s, a) + - end + - # validate conversion + - if !(c in "diouxXDOUeEfFgGaAcCsSpn") + - throw(ArgumentError("invalid printf format string: $(repr(s))")) + - end + - # TODO: warn about silly flag/conversion combinations + - flags, width, precision, c + - end + - + - ### printf formatter generation ### + - + - function special_handler(flags::String, width::Int) + - @gensym x + - blk = Expr(:block) + - pad = '-' in flags ? rpad : lpad + - pos = '+' in flags ? "+" : + - ' ' in flags ? " " : "" + - abn = quote + 0 isnan($x) ? $(pad("NaN", width)) : + - $x < 0 ? $(pad("-Inf", width)) : + - $(pad("$(pos)Inf", width)) + - end + - ex = :(isfinite($x) ? $blk : print(out, $abn)) + - x, ex, blk + - end + - + - function pad(m::Int, n, c::Char) + - if m <= 1 + - :($n > 0 && print(out,$c)) + - else + - @gensym i + - quote + - $i = $n + - while $i > 0 + - print(out,$c) + - $i -= 1 + - end + - end + - end + - end + - + - function dynamic_pad(m, val, c::Char) + - @gensym i + - quote + - if $m <= 1 + - $val > 0 && print(out,$c) + - else + - $i = $val + - while $i > 0 + - print(out,$c) + - $i -= 1 + - end + - end + - end + - end + - + - # returns the number of (ASCII) chars output by print_fixed + - function print_fixed_width(precision, pt, ndigits, trailingzeros=true) + - count = 0 + - if pt <= 0 + - # 0.0dddd0 + - count += 2 + - precision += pt + - if pt < 0 + - count -= pt + - end + - count += ndigits + - precision -= ndigits + - elseif ndigits <= pt + - # dddd000.000000 + - count += ndigits + - if ndigits < pt + - count += pt - ndigits + - end + - count += trailingzeros + - else # 0 < pt < ndigits + - # dd.dd0000 + - ndigits -= pt + - count += pt + 1 + ndigits + - precision -= ndigits + - end + - if trailingzeros && precision > 0 + - count += precision + - end + - return count + - end + - + - # note: if print_fixed is changed, print_fixed_width should be changed accordingly + - function print_fixed(out, precision, pt, ndigits, trailingzeros=true) + - pdigits = pointer(DIGITSs[Threads.threadid()]) + - if pt <= 0 + - # 0.0dddd0 + - print(out, '0') + - print(out, '.') + - precision += pt + - while pt < 0 + - print(out, '0') + - pt += 1 + - end + - unsafe_write(out, pdigits, ndigits) + - precision -= ndigits + - elseif ndigits <= pt + - # dddd000.000000 + - unsafe_write(out, pdigits, ndigits) + - while ndigits < pt + - print(out, '0') + - ndigits += 1 + - end + - if trailingzeros + - print(out, '.') + - end + - else # 0 < pt < ndigits + - # dd.dd0000 + - ndigits -= pt + - unsafe_write(out, pdigits, pt) + - print(out, '.') + - unsafe_write(out, pdigits+pt, ndigits) + - precision -= ndigits + - end + - if trailingzeros + - while precision > 0 + - print(out, '0') + - precision -= 1 + - end + - end + - end + - + - function print_exp_e(out, exp::Integer) + - print(out, exp < 0 ? '-' : '+') + - exp = abs(exp) + - d = div(exp,100) + - if d > 0 + - if d >= 10 + - print(out, exp) + - return + - end + - print(out, Char('0'+d)) + - end + - exp = rem(exp,100) + - print(out, Char('0'+div(exp,10))) + - print(out, Char('0'+rem(exp,10))) + - end + - + - function print_exp_a(out, exp::Integer) + - print(out, exp < 0 ? '-' : '+') + - exp = abs(exp) + - print(out, exp) + - end + - + - + - function gen_d(flags::String, width::Int, precision::Int, c::Char) + - # print integer: + - # [dDiu]: print decimal digits + - # [o]: print octal digits + - # [x]: print hex digits, lowercase + - # [X]: print hex digits, uppercase + - # + - # flags: + - # (#): prefix hex with 0x/0X; octal leads with 0 + - # (0): pad left with zeros + - # (-): left justify + - # ( ): precede non-negative values with " " + - # (+): precede non-negative values with "+" + - # + - x, ex, blk = special_handler(flags,width) + - # interpret the number + - prefix = "" + - if lowercase(c)=='o' + - fn = '#' in flags ? :decode_0ct : :decode_oct + - elseif c=='x' + - '#' in flags && (prefix = "0x") + - fn = :decode_hex + - elseif c=='X' + - '#' in flags && (prefix = "0X") + - fn = :decode_HEX + - else + - fn = :decode_dec + - end + - push!(blk.args, :((do_out, args) = $fn(out, $x, $flags, $width, $precision, $c))) + - ifblk = Expr(:if, :do_out, Expr(:block)) + - push!(blk.args, ifblk) + - blk = ifblk.args[2] + - push!(blk.args, :((len, pt, neg) = args)) + - # calculate padding + - width -= length(prefix) + - space_pad = width > max(1,precision) && '-' in flags || + - precision < 0 && width > 1 && !('0' in flags) || + - precision >= 0 && width > precision + - padding = nothing + - if precision < 1; precision = 1; end + - if space_pad + - if '+' in flags || ' ' in flags + - width -= 1 + - if width > precision + - padding = :($width-(pt > $precision ? pt : $precision)) + - end + - else + - if width > precision + - padding = :($width-neg-(pt > $precision ? pt : $precision)) + - end + - end + - end + - # print space padding + - if padding !== nothing && !('-' in flags) + - push!(blk.args, pad(width-precision, padding, ' ')) + - end + - # print sign + - '+' in flags ? push!(blk.args, :(print(out, neg ? '-' : '+'))) : + - ' ' in flags ? push!(blk.args, :(print(out, neg ? '-' : ' '))) : + - push!(blk.args, :(neg && print(out, '-'))) + - # print prefix + - for ch in prefix + - push!(blk.args, :(print(out, $ch))) + - end + - # print zero padding & leading zeros + - if space_pad && precision > 1 + - push!(blk.args, pad(precision-1, :($precision-pt), '0')) + - elseif !space_pad && width > 1 + - zeros = '+' in flags || ' ' in flags ? :($(width-1)-pt) : :($width-neg-pt) + - push!(blk.args, pad(width-1, zeros, '0')) + - end + - # print integer + - push!(blk.args, :(unsafe_write(out, pointer(DIGITSs[Threads.threadid()]), pt))) + - # print padding + - if padding !== nothing && '-' in flags + - push!(blk.args, pad(width-precision, padding, ' ')) + - end + - # return arg, expr + - :(($x)::Real), ex + - end + - + - function gen_f(flags::String, width::Int, precision::Int, c::Char) + - # print to fixed trailing precision + - # [fF]: the only choice + - # + - # flags + - # (#): always print a decimal point + - # (0): pad left with zeros + - # (-): left justify + - # ( ): precede non-negative values with " " + - # (+): precede non-negative values with "+" + - # + - x, ex, blk = special_handler(flags,width) + - # interpret the number + - if precision < 0; precision = 6; end + - push!(blk.args, :((do_out, args) = fix_dec(out, $x, $flags, $width, $precision, $c))) + - ifblk = Expr(:if, :do_out, Expr(:block)) + - push!(blk.args, ifblk) + - blk = ifblk.args[2] + - push!(blk.args, :((len, pt, neg) = args)) + - # calculate padding + - padding = nothing + - if precision > 0 || '#' in flags + - width -= precision+1 + - end + - if '+' in flags || ' ' in flags + - width -= 1 + - if width > 1 + - padding = :($width-(pt > 0 ? pt : 1)) + - end + - else + - if width > 1 + - padding = :($width-(pt > 0 ? pt : 1)-neg) + - end + - end + - # print space padding + - if padding !== nothing && !('-' in flags) && !('0' in flags) + - push!(blk.args, pad(width-1, padding, ' ')) + - end + - # print sign + - '+' in flags ? push!(blk.args, :(print(out, neg ? '-' : '+'))) : + - ' ' in flags ? push!(blk.args, :(print(out, neg ? '-' : ' '))) : + - push!(blk.args, :(neg && print(out, '-'))) + - # print zero padding + - if padding !== nothing && !('-' in flags) && '0' in flags + - push!(blk.args, pad(width-1, padding, '0')) + - end + - # print digits + - if precision > 0 + - push!(blk.args, :(print_fixed(out,$precision,pt,len))) + - else + - push!(blk.args, :(unsafe_write(out, pointer(DIGITSs[Threads.threadid()]), len))) + - push!(blk.args, :(while pt >= (len+=1) print(out,'0') end)) + - '#' in flags && push!(blk.args, :(print(out, '.'))) + - end + - # print space padding + - if padding !== nothing && '-' in flags + - push!(blk.args, pad(width-1, padding, ' ')) + - end + - # return arg, expr + - :(($x)::Real), ex + - end + - + - function gen_e(flags::String, width::Int, precision::Int, c::Char, inside_g::Bool=false) + - # print float in scientific form: + - # [e]: use 'e' to introduce exponent + - # [E]: use 'E' to introduce exponent + - # + - # flags: + - # (#): always print a decimal point + - # (0): pad left with zeros + - # (-): left justify + - # ( ): precede non-negative values with " " + - # (+): precede non-negative values with "+" + - # + - x, ex, blk = if inside_g + - @gensym x + - blk = Expr(:block) + - x, blk, blk + - else + - special_handler(flags,width) + - end + - # interpret the number + - if precision < 0; precision = 6; end + - ndigits = min(precision+1,length(DIGITSs[Threads.threadid()])-1) + - push!(blk.args, :((do_out, args) = ini_dec(out,$x,$ndigits, $flags, $width, $precision, $c))) + - push!(blk.args, :(digits = DIGITSs[Threads.threadid()])) + - ifblk = Expr(:if, :do_out, Expr(:block)) + - push!(blk.args, ifblk) + - blk = ifblk.args[2] + - push!(blk.args, :((len, pt, neg) = args)) + - push!(blk.args, :(exp = pt-1)) + - expmark = isuppercase(c) ? "E" : "e" + - if precision==0 && '#' in flags + - expmark = string(".",expmark) + - end + - # calculate padding + - padding = nothing + - width -= precision+length(expmark)+(precision>0)+4 + - # 4 = leading + expsign + 2 exp digits + - if '+' in flags || ' ' in flags + - width -= 1 # for the sign indicator + - if width > 0 + - padding = quote + - padn=$width + - if (exp<=-100)|(100<=exp) + - if isa($x,SmallNumber) + - padn -= 1 + - else + - padn -= Base.ndigits0z(exp) - 2 + - end + - end + - padn + - end + - end + - else + - if width > 0 + - padding = quote + - padn=$width-neg + - if (exp<=-100)|(100<=exp) + - if isa($x,SmallNumber) + - padn -= 1 + - else + - padn -= Base.ndigits0z(exp) - 2 + - end + - end + - padn + - end + - end + - end + - # print space padding + - if padding !== nothing && !('-' in flags) && !('0' in flags) + - push!(blk.args, pad(width, padding, ' ')) + - end + - # print sign + - '+' in flags ? push!(blk.args, :(print(out, neg ? '-' : '+'))) : + - ' ' in flags ? push!(blk.args, :(print(out, neg ? '-' : ' '))) : + - push!(blk.args, :(neg && print(out, '-'))) + - # print zero padding + - if padding !== nothing && !('-' in flags) && '0' in flags + - push!(blk.args, pad(width, padding, '0')) + - end + - # print digits + - push!(blk.args, :(write(out, digits[1]))) + - if precision > 0 + - if inside_g && !('#' in flags) + - push!(blk.args, :(endidx = $ndigits; + - while endidx > 1 && digits[endidx] == UInt8('0') + - endidx -= 1 + - end; + - if endidx > 1 + - print(out, '.') + - unsafe_write(out, pointer(digits)+1, endidx-1) + - end + - )) + - else + - push!(blk.args, :(print(out, '.'))) + - push!(blk.args, :(unsafe_write(out, pointer(digits)+1, $(ndigits-1)))) + - if ndigits < precision+1 + - n = precision+1-ndigits + - push!(blk.args, pad(n, n, '0')) + - end + - end + - end + - for ch in expmark + - push!(blk.args, :(print(out, $ch))) + - end + - push!(blk.args, :(print_exp_e(out, exp))) + - # print space padding + - if padding !== nothing && '-' in flags + - push!(blk.args, pad(width, padding, ' ')) + - end + - # return arg, expr + - :(($x)::Real), ex + - end + - + - function gen_a(flags::String, width::Int, precision::Int, c::Char) + - # print float in hexadecimal format + - # [a]: lowercase hex float, e.g. -0x1.cfp-2 + - # [A]: uppercase hex float, e.g. -0X1.CFP-2 + - # + - # flags: + - # (#): always print a decimal point + - # (0): pad left with zeros + - # (-): left justify + - # ( ): precede non-negative values with " " + - # (+): precede non-negative values with "+" + - # + - x, ex, blk = special_handler(flags,width) + - if c == 'A' + - hexmark, expmark = "0X", "P" + - fn = :ini_HEX + - else + - hexmark, expmark = "0x", "p" + - fn = :ini_hex + - end + - # if no precision, print max non-zero + - if precision < 0 + - push!(blk.args, :((do_out, args) = $fn(out,$x, $flags, $width, $precision, $c))) + - else + - ndigits = min(precision+1,length(DIGITSs[Threads.threadid()])-1) + - push!(blk.args, :((do_out, args) = $fn(out,$x,$ndigits, $flags, $width, $precision, $c))) + - end + - push!(blk.args, :(digits = DIGITSs[Threads.threadid()])) + - ifblk = Expr(:if, :do_out, Expr(:block)) + - push!(blk.args, ifblk) + - blk = ifblk.args[2] + - push!(blk.args, :((len, exp, neg) = args)) + - if precision==0 && '#' in flags + - expmark = string(".",expmark) + - end + - # calculate padding + - padding = nothing + - if precision > 0 + - width -= precision+length(hexmark)+length(expmark)+4 + - # 4 = leading + expsign + 1 exp digit + decimal + - else + - width -= length(hexmark)+length(expmark)+3+(precision<0 && '#' in flags) + - # 3 = leading + expsign + 1 exp digit + - end + - if '+' in flags || ' ' in flags + - width -= 1 # for the sign indicator + - if width > 0 + - padding = :($(width+1) - Base.ndigits(exp)) + - end + - else + - if width > 0 + - padding = :($(width+1) - neg - Base.ndigits(exp)) + - end + - end + - if precision < 0 && width > 0 + - if '#' in flags + - padding = :($padding - (len-1)) + - else + - padding = :($padding - (len>1 ? len : 0)) + - end + - end + - # print space padding + - if padding !== nothing && !('-' in flags) && !('0' in flags) + - push!(blk.args, pad(width, padding, ' ')) + - end + - # print sign + - '+' in flags ? push!(blk.args, :(print(out, neg ? '-' : '+'))) : + - ' ' in flags ? push!(blk.args, :(print(out, neg ? '-' : ' '))) : + - push!(blk.args, :(neg && print(out, '-'))) + - # hex prefix + - for ch in hexmark + - push!(blk.args, :(print(out, $ch))) + - end + - # print zero padding + - if padding !== nothing && !('-' in flags) && '0' in flags + - push!(blk.args, pad(width, padding, '0')) + - end + - # print digits: assumes ASCII/UTF8 encoding of digits is okay for `out` + - push!(blk.args, :(write(out, digits[1]))) + - if precision > 0 + - push!(blk.args, :(print(out, '.'))) + - push!(blk.args, :(unsafe_write(out, pointer(digits)+1, $(ndigits-1)))) + - if ndigits < precision+1 + - n = precision+1-ndigits + - push!(blk.args, pad(n, n, '0')) + - end + - elseif precision < 0 + - ifvpblk = Expr(:if, :(len > 1), Expr(:block)) + - vpblk = ifvpblk.args[2] + - if '#' in flags + - push!(blk.args, :(print(out, '.'))) + - else + - push!(vpblk.args, :(print(out, '.'))) + - end + - push!(vpblk.args, :(unsafe_write(out, pointer(digits)+1, len-1))) + - push!(blk.args, ifvpblk) + - end + - for ch in expmark + - push!(blk.args, :(print(out, $ch))) + - end + - push!(blk.args, :(print_exp_a(out, exp))) + - # print space padding + - if padding !== nothing && '-' in flags + - push!(blk.args, pad(width, padding, ' ')) + - end + - # return arg, expr + - :(($x)::Real), ex + - end + - + - function gen_c(flags::String, width::Int, precision::Int, c::Char) + - # print a character: + - # [cC]: both the same for us (Unicode) + - # + - # flags: + - # (0): pad left with zeros + - # (-): left justify + - # + - @gensym x + - blk = Expr(:block, :($x = Char($x))) + - if width > 1 && !('-' in flags) + - p = '0' in flags ? '0' : ' ' + - push!(blk.args, pad(width-1, :($width-textwidth($x)), p)) + - end + - push!(blk.args, :(print(out, $x))) + - if width > 1 && '-' in flags + - push!(blk.args, pad(width-1, :($width-textwidth($x)), ' ')) + - end + - :(($x)::Integer), blk + - end + - + - function _limit(s, prec) + - prec >= sizeof(s) && return s + - p = prevind(s, prec+1) + - n = nextind(s, p)-1 + - s[1:(prec>=n ? n : prevind(s,p))] + - end + - + - function gen_s(flags::String, width::Int, precision::Int, c::Char) + - # print a string: + - # [sS]: both the same for us (Unicode) + - # + - # flags: + - # (-): left justify + - # (#): use `show`/`repr` instead of `print`/`string` + - # + - @gensym x + - blk = Expr(:block) + - if width > 0 + - if !('#' in flags) + - push!(blk.args, :($x = string($x))) + - else + - push!(blk.args, :($x = repr($x))) + - end + - if precision!=-1 + - push!(blk.args, :($x = _limit($x, $precision))) + - end + - if !('-' in flags) + - push!(blk.args, pad(width, :($width-textwidth($x)), ' ')) + - end + - push!(blk.args, :(print(out, $x))) + - if '-' in flags + - push!(blk.args, pad(width, :($width-textwidth($x)), ' ')) + - end + - else + - if precision!=-1 + - push!(blk.args, :(io = IOBuffer())) + - else + - push!(blk.args, :(io = out)) + - end + - if !('#' in flags) + - push!(blk.args, :(print(io, $x))) + - else + - push!(blk.args, :(show(io, $x))) + - end + - if precision!=-1 + - push!(blk.args, :(print(out, _limit(String(take!(io)), $precision)))) + - end + - end + - :(($x)::Any), blk + - end + - + - # TODO: faster pointer printing. + - + - function gen_p(flags::String, width::Int, precision::Int, c::Char) + - # print pointer: + - # [p]: the only option + - # + - # flags: + - # (-): left justify + - # + - @gensym x + - blk = Expr(:block) + - ptrwidth = Sys.WORD_SIZE>>2 + - width -= ptrwidth+2 + - if width > 0 && !('-' in flags) + - push!(blk.args, pad(width, width, ' ')) + - end + - push!(blk.args, :(print(out, '0'))) + - push!(blk.args, :(print(out, 'x'))) + - push!(blk.args, :(print(out, String(string(unsigned($x), pad = $ptrwidth, base = 16))))) + - if width > 0 && '-' in flags + - push!(blk.args, pad(width, width, ' ')) + - end + - :(($x)::Ptr), blk + - end + - + - function gen_g(flags::String, width::Int, precision::Int, c::Char) + - # print to fixed trailing precision + - # [g]: lower case e on scientific + - # [G]: Upper case e on scientific + - # + - # flags + - # (#): always print a decimal point + - # (0): pad left with zeros + - # (-): left justify + - # ( ): precede non-negative values with " " + - # (+): precede non-negative values with "+" + - # + - x, ex, blk = special_handler(flags,width) + - if precision < 0; precision = 6; end + - ndigits = min(precision+1,length(DIGITSs[Threads.threadid()])-1) + - # See if anyone else wants to handle it + - push!(blk.args, :((do_out, args) = ini_dec(out,$x,$ndigits, $flags, $width, $precision, $c))) + - ifblk = Expr(:if, :do_out, Expr(:block)) + - push!(blk.args, ifblk) + - blk = ifblk.args[2] + - push!(blk.args, :((len, pt, neg) = args)) + - push!(blk.args, :(exp = pt-1)) + - push!(blk.args, :(do_f = $precision > exp >= -4)) # Should we interpret like %f or %e? + - feblk = Expr(:if, :do_f, Expr(:block), Expr(:block)) + - push!(blk.args, feblk) + - fblk = feblk.args[2] + - eblk = feblk.args[3] + - + - ### %f branch + - # Follow the same logic as gen_f() but more work has to be deferred until runtime + - # because precision is unknown until then. + - push!(fblk.args, :(fprec = $precision - (exp+1))) + - push!(fblk.args, :((do_out, args) = fix_dec(out, $x, $flags, $width, fprec, $c - 1))) + - fifblk = Expr(:if, :do_out, Expr(:block)) + - push!(fblk.args, fifblk) + - blk = fifblk.args[2] + - push!(blk.args, :((len, pt, neg) = args)) + - push!(blk.args, :(padding = 0)) + - push!(blk.args, :(width = $width)) + - # need to compute value before left-padding since trailing zeros are elided + - push!(blk.args, :(width -= print_fixed_width(fprec,pt,len,$('#' in flags)))) + - if '+' in flags || ' ' in flags + - push!(blk.args, :(width -= 1)) + - else + - push!(blk.args, :(if neg width -= 1; end)) + - end + - push!(blk.args, :(if width >= 1 padding = width; end)) + - # print space padding + - if !('-' in flags) && !('0' in flags) + - padexpr = dynamic_pad(:width, :padding, ' ') + - push!(blk.args, :(if padding > 0 + - $padexpr; end)) + - end + - # print sign + - '+' in flags ? push!(blk.args, :(print(out, neg ? '-' : '+'))) : + - ' ' in flags ? push!(blk.args, :(print(out, neg ? '-' : ' '))) : + - push!(blk.args, :(neg && print(out, '-'))) + - # print zero padding + - if !('-' in flags) && '0' in flags + - padexpr = dynamic_pad(:width, :padding, '0') + - push!(blk.args, :(if padding > 0 + - $padexpr; end)) + - end + - # finally print value + - push!(blk.args, :(print_fixed(out,fprec,pt,len,$('#' in flags)))) + - # print space padding + - if '-' in flags + - padexpr = dynamic_pad(:width, :padding, ' ') + - push!(blk.args, :(if padding > 0 + - $padexpr; end)) + - end + - + - ### %e branch + - # Here we can do all the work at macro expansion time + - var, eex = gen_e(flags, width, precision-1, c, true) + - push!(eblk.args, :($(var.args[1]) = $x)) + - push!(eblk.args, eex) + - + - :(($x)::Real), ex + - end + - + - ### core unsigned integer decoding functions ### + - + - macro handle_zero(ex, digits) + - quote + - if $(esc(ex)) == 0 + - $(esc(digits))[1] = '0' + - return Int32(1), Int32(1), $(esc(:neg)) + - end + - end + - end + - + - decode_oct(out, d, flags::String, width::Int, precision::Int, c::Char) = (true, decode_oct(d)) + - decode_0ct(out, d, flags::String, width::Int, precision::Int, c::Char) = (true, decode_0ct(d)) + - decode_dec(out, d, flags::String, width::Int, precision::Int, c::Char) = (true, decode_dec(d)) + - decode_hex(out, d, flags::String, width::Int, precision::Int, c::Char) = (true, decode_hex(d)) + - decode_HEX(out, d, flags::String, width::Int, precision::Int, c::Char) = (true, decode_HEX(d)) + - fix_dec(out, d, flags::String, width::Int, precision::Int, c::Char) = (true, fix_dec(d, precision)) + - ini_dec(out, d, ndigits::Int, flags::String, width::Int, precision::Int, c::Char) = (true, ini_dec(d, ndigits)) + - ini_hex(out, d, ndigits::Int, flags::String, width::Int, precision::Int, c::Char) = (true, ini_hex(d, ndigits)) + - ini_HEX(out, d, ndigits::Int, flags::String, width::Int, precision::Int, c::Char) = (true, ini_HEX(d, ndigits)) + - ini_hex(out, d, flags::String, width::Int, precision::Int, c::Char) = (true, ini_hex(d)) + - ini_HEX(out, d, flags::String, width::Int, precision::Int, c::Char) = (true, ini_HEX(d)) + - + - + - # fallbacks for Real types without explicit decode_* implementation + - decode_oct(d::Real) = decode_oct(Integer(d)) + - decode_0ct(d::Real) = decode_0ct(Integer(d)) + - decode_dec(d::Real) = decode_dec(Integer(d)) + - decode_hex(d::Real) = decode_hex(Integer(d)) + - decode_HEX(d::Real) = decode_HEX(Integer(d)) + - + - handlenegative(d::Unsigned) = (false, d) + - function handlenegative(d::Integer) + - if d < 0 + - return true, unsigned(oftype(d,-d)) + - else + - return false, unsigned(d) + - end + - end + - + - function decode_oct(d::Integer) + - neg, x = handlenegative(d) + - digits = DIGITSs[Threads.threadid()] + - @handle_zero x digits + - pt = i = div((sizeof(x)<<3)-leading_zeros(x)+2,3) + - while i > 0 + - digits[i] = 48+(x&0x7) + - x >>= 3 + - i -= 1 + - end + - return Int32(pt), Int32(pt), neg + - end + - + - function decode_0ct(d::Integer) + - neg, x = handlenegative(d) + - # doesn't need special handling for zero + - pt = i = div((sizeof(x)<<3)-leading_zeros(x)+5,3) + - digits = DIGITSs[Threads.threadid()] + - while i > 0 + - digits[i] = 48+(x&0x7) + - x >>= 3 + - i -= 1 + - end + - return Int32(pt), Int32(pt), neg + - end + - + - function decode_dec(d::Integer) + - neg, x = handlenegative(d) + - digits = DIGITSs[Threads.threadid()] + - @handle_zero x digits + - pt = i = Base.ndigits0z(x) + - while i > 0 + - digits[i] = 48+rem(x,10) + - x = div(x,10) + - i -= 1 + - end + - return Int32(pt), Int32(pt), neg + - end + - + - function decode_hex(d::Integer, symbols::AbstractArray{UInt8,1}) + - neg, x = handlenegative(d) + - digits = DIGITSs[Threads.threadid()] + - @handle_zero x digits + - pt = i = (sizeof(x)<<1)-(leading_zeros(x)>>2) + - while i > 0 + - digits[i] = symbols[(x&0xf)+1] + - x >>= 4 + - i -= 1 + - end + - return Int32(pt), Int32(pt), neg + - end + - + - const hex_symbols = b"0123456789abcdef" + - const HEX_symbols = b"0123456789ABCDEF" + - + - decode_hex(x::Integer) = decode_hex(x,hex_symbols) + - decode_HEX(x::Integer) = decode_hex(x,HEX_symbols) + - + - function decode(b::Int, x::BigInt) + - neg = x.size < 0 + - pt = Base.ndigits(x, base=abs(b)) + - digits = DIGITSs[Threads.threadid()] + - length(digits) < pt+1 && resize!(digits, pt+1) + - neg && (x.size = -x.size) + - GMP.MPZ.get_str!(digits, b, x) + - neg && (x.size = -x.size) + - return Int32(pt), Int32(pt), neg + - end + - decode_oct(x::BigInt) = decode(8, x) + - decode_dec(x::BigInt) = decode(10, x) + - decode_hex(x::BigInt) = decode(16, x) + - decode_HEX(x::BigInt) = decode(-16, x) + - + - function decode_0ct(x::BigInt) + - neg = x.size < 0 + - digits = DIGITSs[Threads.threadid()] + - digits[1] = '0' + - if x.size == 0 + - return Int32(1), Int32(1), neg + - end + - pt = Base.ndigits0z(x, 8) + 1 + - length(digits) < pt+1 && resize!(digits, pt+1) + - neg && (x.size = -x.size) + - p = convert(Ptr{UInt8}, digits) + 1 + - GMP.MPZ.get_str!(p, 8, x) + - neg && (x.size = -x.size) + - return neg, Int32(pt), Int32(pt) + - end + - + - ### decoding functions directly used by printf generated code ### + - + - # decode_*(x)=> fixed precision, to 0th place, filled out + - # fix_*(x,n) => fixed precision, to nth place, not filled out + - # ini_*(x,n) => n initial digits, filled out + - + - # alternate versions: + - # *_0ct(x,n) => ensure that the first octal digits is zero + - # *_HEX(x,n) => use uppercase digits for hexadecimal + - + - # - returns (len, point, neg) + - # - implies len = point + - # + - + - function decode_dec(x::SmallFloatingPoint) + - digits = DIGITSs[Threads.threadid()] + - if x == 0.0 + - digits[1] = '0' + - return (Int32(1), Int32(1), false) + - end + - len,pt,neg = grisu(x,Grisu.FIXED,0) + - if len == 0 + - digits[1] = '0' + - return (Int32(1), Int32(1), false) + - else + - for i = len+1:pt + - digits[i] = '0' + - end + - end + - return Int32(len), Int32(pt), neg + - end + - # TODO: implement decode_oct, decode_0ct, decode_hex, decode_HEX for SmallFloatingPoint + - + - ## fix decoding functions ## + - # + - # - returns (neg, point, len) + - # - if len less than point, trailing zeros implied + - # + - + - # fallback for Real types without explicit fix_dec implementation + - fix_dec(x::Real, n::Int) = fix_dec(float(x),n) + - + - fix_dec(x::Integer, n::Int) = decode_dec(x) + - + - function fix_dec(x::SmallFloatingPoint, n::Int) + - digits = DIGITSs[Threads.threadid()] + - if n > length(digits)-1; n = length(digits)-1; end + - len,pt,neg = grisu(x,Grisu.FIXED,n) + - if len == 0 + - digits[1] = '0' + - return (Int32(1), Int32(1), neg) + - end + - return Int32(len), Int32(pt), neg + - end + - + - ## ini decoding functions ## + - # + - # - returns (neg, point, len) + - # - implies len = n (requested digits) + - # + - + - # fallback for Real types without explicit fix_dec implementation + - ini_dec(x::Real, n::Int) = ini_dec(float(x),n) + - + - function ini_dec(d::Integer, n::Int) + - neg, x = handlenegative(d) + - k = ndigits(x) + - digits = DIGITSs[Threads.threadid()] + - if k <= n + - pt = k + - for i = k:-1:1 + - digits[i] = '0'+rem(x,10) + - x = div(x,10) + - end + - for i = k+1:n + - digits[i] = '0' + - end + - else + - p = Base.powers_of_ten[k-n+1] + - r = rem(x,p) + - if r >= (p>>1) + - x += p + - if x >= Base.powers_of_ten[k+1] + - p *= 10 + - k += 1 + - end + - end + - pt = k + - x = div(x,p) + - for i = n:-1:1 + - digits[i] = '0'+rem(x,10) + - x = div(x,10) + - end + - end + - return n, pt, neg + - end + - + - function ini_dec(x::SmallFloatingPoint, n::Int) + - if x == 0.0 + - ccall(:memset, Ptr{Cvoid}, (Ptr{Cvoid}, Cint, Csize_t), DIGITSs[Threads.threadid()], '0', n) + - return Int32(1), Int32(1), signbit(x) + - else + - len,pt,neg = grisu(x,Grisu.PRECISION,n) + - end + - return Int32(len), Int32(pt), neg + - end + - + - function ini_dec(x::BigInt, n::Int) + - if x.size == 0 + - ccall(:memset, Ptr{Cvoid}, (Ptr{Cvoid}, Cint, Csize_t), DIGITSs[Threads.threadid()], '0', n) + - return Int32(1), Int32(1), false + - end + - d = Base.ndigits0z(x) + - if d <= n + - info = decode_dec(x) + - d == n && return info + - p = convert(Ptr{Cvoid}, DIGITSs[Threads.threadid()]) + info[2] + - ccall(:memset, Ptr{Cvoid}, (Ptr{Cvoid}, Cint, Csize_t), p, '0', n - info[2]) + - return info + - end + - return (n, d, decode_dec(round(BigInt,x/big(10)^(d-n)))[3]) + - end + - + - + - ini_hex(x::Real, n::Int) = ini_hex(x,n,hex_symbols) + - ini_HEX(x::Real, n::Int) = ini_hex(x,n,HEX_symbols) + - + - ini_hex(x::Real) = ini_hex(x,hex_symbols) + - ini_HEX(x::Real) = ini_hex(x,HEX_symbols) + - + - ini_hex(x::Real, n::Int, symbols::AbstractArray{UInt8,1}) = ini_hex(float(x), n, symbols) + - ini_hex(x::Real, symbols::AbstractArray{UInt8,1}) = ini_hex(float(x), symbols) + - + - function ini_hex(x::SmallFloatingPoint, n::Int, symbols::AbstractArray{UInt8,1}) + - x = Float64(x) + - digits = DIGITSs[Threads.threadid()] + - if x == 0.0 + - ccall(:memset, Ptr{Cvoid}, (Ptr{Cvoid}, Cint, Csize_t), digits, '0', n) + - return Int32(1), Int32(0), signbit(x) + - else + - s, p = frexp(x) + - sigbits = 4*min(n-1,13) + - s = 0.25*round(ldexp(s,1+sigbits)) + - # ensure last 2 exponent bits either 01 or 10 + - u = (reinterpret(UInt64,s) & 0x003f_ffff_ffff_ffff) >> (52-sigbits) + - if n > 14 + - ccall(:memset, Ptr{Cvoid}, (Ptr{Cvoid}, Cint, Csize_t), digits, '0', n) + - end + - i = (sizeof(u)<<1)-(leading_zeros(u)>>2) + - while i > 0 + - digits[i] = symbols[(u&0xf)+1] + - u >>= 4 + - i -= 1 + - end + - # pt is the binary exponent + - return Int32(n), Int32(p-1), x < 0.0 + - end + - end + - + - function ini_hex(x::SmallFloatingPoint, symbols::AbstractArray{UInt8,1}) + - x = Float64(x) + - digits = DIGITSs[Threads.threadid()] + - if x == 0.0 + - ccall(:memset, Ptr{Cvoid}, (Ptr{Cvoid}, Cint, Csize_t), digits, '0', 1) + - return Int32(1), Int32(0), signbit(x) + - else + - s, p = frexp(x) + - s *= 2.0 + - u = (reinterpret(UInt64,s) & 0x001f_ffff_ffff_ffff) + - t = (trailing_zeros(u) >> 2) + - u >>= (t<<2) + - n = 14-t + - for i = n:-1:1 + - digits[i] = symbols[(u&0xf)+1] + - u >>= 4 + - end + - # pt is the binary exponent + - return Int32(n), Int32(p-1), x < 0.0 + - end + - end + - + - function ini_hex(x::Integer) + - len,pt,neg = decode_hex(x) + - pt = (len-1)<<2 + - len,pt,neg + - end + - function ini_HEX(x::Integer) + - len,pt,neg = decode_HEX(x) + - pt = (len-1)<<2 + - len,pt,neg + - end + - + - # not implemented + - ini_hex(x::Integer,ndigits::Int) = throw(MethodError(ini_hex,(x,ndigits))) + - + - #BigFloat + - fix_dec(out, d::BigFloat, flags::String, width::Int, precision::Int, c::Char) = bigfloat_printf(out, d, flags, width, precision, c) + - ini_dec(out, d::BigFloat, ndigits::Int, flags::String, width::Int, precision::Int, c::Char) = bigfloat_printf(out, d, flags, width, precision, c) + - ini_hex(out, d::BigFloat, ndigits::Int, flags::String, width::Int, precision::Int, c::Char) = bigfloat_printf(out, d, flags, width, precision, c) + - ini_HEX(out, d::BigFloat, ndigits::Int, flags::String, width::Int, precision::Int, c::Char) = bigfloat_printf(out, d, flags, width, precision, c) + - ini_hex(out, d::BigFloat, flags::String, width::Int, precision::Int, c::Char) = bigfloat_printf(out, d, flags, width, precision, c) + - ini_HEX(out, d::BigFloat, flags::String, width::Int, precision::Int, c::Char) = bigfloat_printf(out, d, flags, width, precision, c) + - function bigfloat_printf(out, d::BigFloat, flags::String, width::Int, precision::Int, c::Char) + - fmt_len = sizeof(flags)+4 + - if width > 0 + - fmt_len += ndigits(width) + - end + - if precision >= 0 + - fmt_len += ndigits(precision)+1 + - end + - fmt = IOBuffer(maxsize=fmt_len) + - print(fmt, '%') + - print(fmt, flags) + - if width > 0 + - print(fmt, width) + - end + - if precision == 0 + - print(fmt, '.') + - print(fmt, '0') + - elseif precision > 0 + - print(fmt, '.') + - print(fmt, precision) + - end + - print(fmt, 'R') + - print(fmt, c) + - write(fmt, UInt8(0)) + - printf_fmt = take!(fmt) + - @assert length(printf_fmt) == fmt_len + - digits = DIGITSs[Threads.threadid()] + - bufsiz = length(digits) + - lng = ccall((:mpfr_snprintf,:libmpfr), Int32, + - (Ptr{UInt8}, Culong, Ptr{UInt8}, Ref{BigFloat}...), + - digits, bufsiz, printf_fmt, d) + - lng > 0 || error("invalid printf formatting for BigFloat") + - unsafe_write(out, pointer(digits), min(lng, bufsiz-1)) + - return (false, ()) + - end + - + - ### external printf interface ### + - + - is_str_expr(ex) = + - isa(ex,Expr) && (ex.head == :string || (ex.head == :macrocall && isa(ex.args[1],Symbol) && + - endswith(string(ex.args[1]),"str"))) + - + - function _printf(macroname, io, fmt, args) + - isa(fmt, AbstractString) || throw(ArgumentError("$macroname: format must be a plain static string (no interpolation or prefix)")) + - sym_args, blk = gen(fmt) + - + - has_splatting = false + - for arg in args + - if isa(arg, Expr) && arg.head == :... + - has_splatting = true + - break + - end + - end + - + - # + - # Immediately check for corresponding arguments if there is no splatting + - # + - if !has_splatting && length(sym_args) != length(args) + - throw(ArgumentError("$macroname: wrong number of arguments ($(length(args))) should be ($(length(sym_args)))")) + - end + - + - for i = length(sym_args):-1:1 + - var = sym_args[i].args[1] + - if has_splatting + - pushfirst!(blk.args, :($var = G[$i])) + - else + - pushfirst!(blk.args, :($var = $(esc(args[i])))) + - end + - end + - + - # + - # Delay generation of argument list and check until evaluation time instead of macro + - # expansion time if there is splatting. + - # + - if has_splatting + - x = Expr(:call,:tuple,args...) + - pushfirst!(blk.args, + - quote + - G = $(esc(x)) + - if length(G) != $(length(sym_args)) + - throw(ArgumentError(string($macroname,": wrong number of arguments (",length(G),") should be (",$(length(sym_args)),")"))) + - end + - end + - ) + - end + - + - pushfirst!(blk.args, :(out = $io)) + - Expr(:let, Expr(:block), blk) + - end + - + - macro printf(args...) + - isempty(args) && throw(ArgumentError("@printf: called with no arguments")) + - if isa(args[1], AbstractString) || is_str_expr(args[1]) + - _printf("@printf", :stdout, args[1], args[2:end]) + - else + - (length(args) >= 2 && (isa(args[2], AbstractString) || is_str_expr(args[2]))) || + - throw(ArgumentError("@printf: first or second argument must be a format string")) + - _printf("@printf", esc(args[1]), args[2], args[3:end]) + - end + - end + - + - macro sprintf(args...) + - isempty(args) && throw(ArgumentError("@sprintf: called with zero arguments")) + - isa(args[1], AbstractString) || is_str_expr(args[1]) || + - throw(ArgumentError("@sprintf: first argument must be a format string")) + - letexpr = _printf("@sprintf", :(IOBuffer()), args[1], args[2:end]) + - push!(letexpr.args[2].args, :(String(take!(out)))) + - letexpr + - end + - + - end # module + - diff --git a/profiling/julia-1.0.4/share/julia/base/util.jl.19966.cov b/profiling/julia-1.0.4/share/julia/base/util.jl.19966.cov new file mode 100644 index 0000000000000000000000000000000000000000..66e3774326c44cb665658dbbc05eaaf220be2515 --- /dev/null +++ b/profiling/julia-1.0.4/share/julia/base/util.jl.19966.cov @@ -0,0 +1,738 @@ + - # This file is a part of Julia. License is MIT: https://julialang.org/license + - + - + - # This type must be kept in sync with the C struct in src/gc.h + - struct GC_Num + - allocd ::Int64 # GC internal + - deferred_alloc::Int64 # GC internal + - freed ::Int64 # GC internal + - malloc ::UInt64 + - realloc ::UInt64 + - poolalloc ::UInt64 + - bigalloc ::UInt64 + - freecall ::UInt64 + - total_time ::UInt64 + - total_allocd::UInt64 # GC internal + - since_sweep ::UInt64 # GC internal + - collect ::Csize_t # GC internal + - pause ::Cint + - full_sweep ::Cint + - end + - + - gc_num() = ccall(:jl_gc_num, GC_Num, ()) + - + - # This type is to represent differences in the counters, so fields may be negative + - struct GC_Diff + - allocd ::Int64 # Bytes allocated + - malloc ::Int64 # Number of GC aware malloc() + - realloc ::Int64 # Number of GC aware realloc() + - poolalloc ::Int64 # Number of pool allocation + - bigalloc ::Int64 # Number of big (non-pool) allocation + - freecall ::Int64 # Number of GC aware free() + - total_time ::Int64 # Time spent in garbage collection + - pause ::Int64 # Number of GC pauses + - full_sweep ::Int64 # Number of GC full collection + - end + - + - gc_total_bytes(gc_num::GC_Num) = + - (gc_num.allocd + gc_num.deferred_alloc + + - Int64(gc_num.collect) + Int64(gc_num.total_allocd)) + - + - function GC_Diff(new::GC_Num, old::GC_Num) + - # logic from `src/gc.c:jl_gc_total_bytes` + - old_allocd = gc_total_bytes(old) + - new_allocd = gc_total_bytes(new) + - return GC_Diff(new_allocd - old_allocd, + - Int64(new.malloc - old.malloc), + - Int64(new.realloc - old.realloc), + - Int64(new.poolalloc - old.poolalloc), + - Int64(new.bigalloc - old.bigalloc), + - Int64(new.freecall - old.freecall), + - Int64(new.total_time - old.total_time), + - new.pause - old.pause, + - new.full_sweep - old.full_sweep) + - end + - + - function gc_alloc_count(diff::GC_Diff) + - diff.malloc + diff.realloc + diff.poolalloc + diff.bigalloc + - end + - + - + - # total time spend in garbage collection, in nanoseconds + - gc_time_ns() = ccall(:jl_gc_total_hrtime, UInt64, ()) + - + - # total number of bytes allocated so far + - gc_bytes() = ccall(:jl_gc_total_bytes, Int64, ()) + - + - # print elapsed time, return expression value + - const _mem_units = ["byte", "KiB", "MiB", "GiB", "TiB", "PiB"] + - const _cnt_units = ["", " k", " M", " G", " T", " P"] + - function prettyprint_getunits(value, numunits, factor) + - if value == 0 || value == 1 + - return (value, 1) + - end + - unit = ceil(Int, log(value) / log(factor)) + - unit = min(numunits, unit) + - number = value/factor^(unit-1) + - return number, unit + - end + - + - function padded_nonzero_print(value,str) + - if value != 0 + - blanks = " "[1:18-length(str)] + - println("$str:$blanks$value") + - end + - end + - + - function format_bytes(bytes) + - bytes, mb = prettyprint_getunits(bytes, length(_mem_units), Int64(1024)) + - if mb == 1 + - Printf.@sprintf("%d %s%s", bytes, _mem_units[mb], bytes==1 ? "" : "s") + - else + - Printf.@sprintf("%.3f %s", bytes, _mem_units[mb]) + - end + - end + - + - function time_print(elapsedtime, bytes=0, gctime=0, allocs=0) + - Printf.@printf("%10.6f seconds", elapsedtime/1e9) + - if bytes != 0 || allocs != 0 + - allocs, ma = prettyprint_getunits(allocs, length(_cnt_units), Int64(1000)) + - if ma == 1 + - Printf.@printf(" (%d%s allocation%s: ", allocs, _cnt_units[ma], allocs==1 ? "" : "s") + - else + - Printf.@printf(" (%.2f%s allocations: ", allocs, _cnt_units[ma]) + - end + - print(format_bytes(bytes)) + - if gctime > 0 + - Printf.@printf(", %.2f%% gc time", 100*gctime/elapsedtime) + - end + - print(")") + - elseif gctime > 0 + - Printf.@printf(", %.2f%% gc time", 100*gctime/elapsedtime) + - end + - end + - + - function timev_print(elapsedtime, diff::GC_Diff) + - allocs = gc_alloc_count(diff) + - time_print(elapsedtime, diff.allocd, diff.total_time, allocs) + - print("\nelapsed time (ns): $elapsedtime\n") + - padded_nonzero_print(diff.total_time, "gc time (ns)") + - padded_nonzero_print(diff.allocd, "bytes allocated") + - padded_nonzero_print(diff.poolalloc, "pool allocs") + - padded_nonzero_print(diff.bigalloc, "non-pool GC allocs") + - padded_nonzero_print(diff.malloc, "malloc() calls") + - padded_nonzero_print(diff.realloc, "realloc() calls") + - padded_nonzero_print(diff.freecall, "free() calls") + - padded_nonzero_print(diff.pause, "GC pauses") + - padded_nonzero_print(diff.full_sweep, "full collections") + - end + - + - """ + - @time + - + - A macro to execute an expression, printing the time it took to execute, the number of + - allocations, and the total number of bytes its execution caused to be allocated, before + - returning the value of the expression. + - + - See also [`@timev`](@ref), [`@timed`](@ref), [`@elapsed`](@ref), and + - [`@allocated`](@ref). + - + - ```julia-repl + - julia> @time rand(10^6); + - 0.001525 seconds (7 allocations: 7.630 MiB) + - + - julia> @time begin + - sleep(0.3) + - 1+1 + - end + - 0.301395 seconds (8 allocations: 336 bytes) + - 2 + - ``` + - """ + - macro time(ex) + - quote + - local stats = gc_num() + - local elapsedtime = time_ns() + - local val = $(esc(ex)) + - elapsedtime = time_ns() - elapsedtime + - local diff = GC_Diff(gc_num(), stats) + - time_print(elapsedtime, diff.allocd, diff.total_time, + - gc_alloc_count(diff)) + - println() + - val + - end + - end + - + - """ + - @timev + - + - This is a verbose version of the `@time` macro. It first prints the same information as + - `@time`, then any non-zero memory allocation counters, and then returns the value of the + - expression. + - + - See also [`@time`](@ref), [`@timed`](@ref), [`@elapsed`](@ref), and + - [`@allocated`](@ref). + - + - ```julia-repl + - julia> @timev rand(10^6); + - 0.001006 seconds (7 allocations: 7.630 MiB) + - elapsed time (ns): 1005567 + - bytes allocated: 8000256 + - pool allocs: 6 + - malloc() calls: 1 + - ``` + - """ + - macro timev(ex) + - quote + - local stats = gc_num() + - local elapsedtime = time_ns() + - local val = $(esc(ex)) + - elapsedtime = time_ns() - elapsedtime + - timev_print(elapsedtime, GC_Diff(gc_num(), stats)) + - val + - end + - end + - + - """ + - @elapsed + - + - A macro to evaluate an expression, discarding the resulting value, instead returning the + - number of seconds it took to execute as a floating-point number. + - + - See also [`@time`](@ref), [`@timev`](@ref), [`@timed`](@ref), + - and [`@allocated`](@ref). + - + - ```julia-repl + - julia> @elapsed sleep(0.3) + - 0.301391426 + - ``` + - """ + - macro elapsed(ex) + - quote + - local t0 = time_ns() + - local val = $(esc(ex)) + - (time_ns()-t0)/1e9 + - end + - end + - + - # measure bytes allocated without *most* contamination from compilation + - # Note: This reports a different value from the @time macros, because + - # it wraps the call in a function, however, this means that things + - # like: @allocated y = foo() + - # will not work correctly, because it will set y in the context of + - # the local function made by the macro, not the current function + - """ + - @allocated + - + - A macro to evaluate an expression, discarding the resulting value, instead returning the + - total number of bytes allocated during evaluation of the expression. Note: the expression is + - evaluated inside a local function, instead of the current context, in order to eliminate the + - effects of compilation, however, there still may be some allocations due to JIT compilation. + - This also makes the results inconsistent with the `@time` macros, which do not try to adjust + - for the effects of compilation. + - + - See also [`@time`](@ref), [`@timev`](@ref), [`@timed`](@ref), + - and [`@elapsed`](@ref). + - + - ```julia-repl + - julia> @allocated rand(10^6) + - 8000080 + - ``` + - """ + - macro allocated(ex) + - quote + - let + - local f + - function f() + 1 b0 = gc_bytes() + 1 $(esc(ex)) + 1 gc_bytes() - b0 + - end + - f() + - end + - end + - end + - + - """ + - @timed + - + - A macro to execute an expression, and return the value of the expression, elapsed time, + - total bytes allocated, garbage collection time, and an object with various memory allocation + - counters. + - + - See also [`@time`](@ref), [`@timev`](@ref), [`@elapsed`](@ref), and + - [`@allocated`](@ref). + - + - ```julia-repl + - julia> val, t, bytes, gctime, memallocs = @timed rand(10^6); + - + - julia> t + - 0.006634834 + - + - julia> bytes + - 8000256 + - + - julia> gctime + - 0.0055765 + - + - julia> fieldnames(typeof(memallocs)) + - (:allocd, :malloc, :realloc, :poolalloc, :bigalloc, :freecall, :total_time, :pause, :full_sweep) + - + - julia> memallocs.total_time + - 5576500 + - ``` + - """ + - macro timed(ex) + - quote + - local stats = gc_num() + - local elapsedtime = time_ns() + - local val = $(esc(ex)) + - elapsedtime = time_ns() - elapsedtime + - local diff = GC_Diff(gc_num(), stats) + - val, elapsedtime/1e9, diff.allocd, diff.total_time/1e9, diff + - end + - end + - + - + - ## printing with color ## + - + - const text_colors = AnyDict( + - :black => "\033[30m", + - :red => "\033[31m", + - :green => "\033[32m", + - :yellow => "\033[33m", + - :blue => "\033[34m", + - :magenta => "\033[35m", + - :cyan => "\033[36m", + - :white => "\033[37m", + - :light_black => "\033[90m", # gray + - :light_red => "\033[91m", + - :light_green => "\033[92m", + - :light_yellow => "\033[93m", + - :light_blue => "\033[94m", + - :light_magenta => "\033[95m", + - :light_cyan => "\033[96m", + - :normal => "\033[0m", + - :default => "\033[39m", + - :bold => "\033[1m", + - :underline => "\033[4m", + - :blink => "\033[5m", + - :reverse => "\033[7m", + - :hidden => "\033[8m", + - :nothing => "", + - ) + - + - for i in 0:255 + - text_colors[i] = "\033[38;5;$(i)m" + - end + - + - const disable_text_style = AnyDict( + - :bold => "\033[22m", + - :underline => "\033[24m", + - :blink => "\033[25m", + - :reverse => "\033[27m", + - :hidden => "\033[28m", + - :normal => "", + - :default => "", + - :nothing => "", + - ) + - + - # Create a docstring with an automatically generated list + - # of colors. + - available_text_colors = collect(Iterators.filter(x -> !isa(x, Integer), keys(text_colors))) + - const possible_formatting_symbols = [:normal, :bold, :default] + - available_text_colors = cat( + - sort!(intersect(available_text_colors, possible_formatting_symbols), rev=true), + - sort!(setdiff( available_text_colors, possible_formatting_symbols)); + - dims=1) + - + - const available_text_colors_docstring = + - string(join([string("`:", key,"`") + - for key in available_text_colors], ",\n", ", or \n")) + - + - """Dictionary of color codes for the terminal. + - + - Available colors are: $available_text_colors_docstring as well as the integers 0 to 255 inclusive. + - + - The color `:default` will print text in the default color while the color `:normal` + - will print text with all text properties (like boldness) reset. + - Printing with the color `:nothing` will print the string without modifications. + - """ + - text_colors + - + - function with_output_color(f::Function, color::Union{Int, Symbol}, io::IO, args...; bold::Bool = false) + - buf = IOBuffer() + - iscolor = get(io, :color, false) + - try f(IOContext(buf, io), args...) + - finally + - str = String(take!(buf)) + - if !iscolor + - print(io, str) + - else + - bold && color == :bold && (color = :nothing) + - enable_ansi = get(text_colors, color, text_colors[:default]) * + - (bold ? text_colors[:bold] : "") + - disable_ansi = (bold ? disable_text_style[:bold] : "") * + - get(disable_text_style, color, text_colors[:default]) + - first = true + - for line in split(str, '\n') + - first || print(buf, '\n') + - first = false + - isempty(line) && continue + - print(buf, enable_ansi, line, disable_ansi) + - end + - print(io, String(take!(buf))) + - end + - end + - end + - + - """ + - printstyled([io], xs...; bold::Bool=false, color::Union{Symbol,Int}=:normal) + - + - Print `xs` in a color specified as a symbol or integer, optionally in bold. + - + - `color` may take any of the values $(Base.available_text_colors_docstring) + - or an integer between 0 and 255 inclusive. Note that not all terminals support 256 colors. + - If the keyword `bold` is given as `true`, the result will be printed in bold. + - """ + - printstyled(io::IO, msg...; bold::Bool=false, color::Union{Int,Symbol}=:normal) = + - with_output_color(print, color, io, msg...; bold=bold) + - printstyled(msg...; bold::Bool=false, color::Union{Int,Symbol}=:normal) = + - printstyled(stdout, msg...; bold=bold, color=color) + - + - function julia_cmd(julia=joinpath(Sys.BINDIR::String, julia_exename())) + - opts = JLOptions() + - cpu_target = unsafe_string(opts.cpu_target) + - image_file = unsafe_string(opts.image_file) + - compile = if opts.compile_enabled == 0 + - "no" + - elseif opts.compile_enabled == 2 + - "all" + - elseif opts.compile_enabled == 3 + - "min" + - else + - "yes" + - end + - depwarn = if opts.depwarn == 0 + - "no" + - elseif opts.depwarn == 2 + - "error" + - else + - "yes" + - end + - `$julia -C$cpu_target -J$image_file --compile=$compile --depwarn=$depwarn` + - end + - + - function julia_exename() + - if ccall(:jl_is_debugbuild, Cint, ()) == 0 + - return @static Sys.iswindows() ? "julia.exe" : "julia" + - else + - return @static Sys.iswindows() ? "julia-debug.exe" : "julia-debug" + - end + - end + - + - """ + - securezero!(o) + - + - `securezero!` fills the memory associated with an object `o` with zeros. + - Unlike `fill!(o,0)` and similar code, which might be optimized away by + - the compiler for objects about to be discarded, the `securezero!` function + - will always be called. + - """ + - function securezero! end + - @noinline securezero!(a::AbstractArray{<:Number}) = fill!(a, 0) + - @noinline unsafe_securezero!(p::Ptr{T}, len::Integer=1) where {T} = + - ccall(:memset, Ptr{T}, (Ptr{T}, Cint, Csize_t), p, 0, len*sizeof(T)) + - unsafe_securezero!(p::Ptr{Cvoid}, len::Integer=1) = Ptr{Cvoid}(unsafe_securezero!(Ptr{UInt8}(p), len)) + - + - """ + - Base.getpass(message::AbstractString) -> Base.SecretBuffer + - + - Display a message and wait for the user to input a secret, returning an `IO` + - object containing the secret. + - + - Note that on Windows, the secret might be displayed as it is typed; see + - `Base.winprompt` for securely retrieving username/password pairs from a + - graphical interface. + - """ + - function getpass end + - + - if Sys.iswindows() + - function getpass(input::TTY, output::IO, prompt::AbstractString) + - input === stdin || throw(ArgumentError("getpass only works for stdin")) + - print(output, prompt, ": ") + - flush(output) + - s = SecretBuffer() + - plen = 0 + - while true + - c = UInt8(ccall(:_getch, Cint, ())) + - if c == 0xff || c == UInt8('\n') || c == UInt8('\r') + - break # EOF or return + - elseif c == 0x00 || c == 0xe0 + - ccall(:_getch, Cint, ()) # ignore function/arrow keys + - elseif c == UInt8('\b') && plen > 0 + - plen -= 1 # delete last character on backspace + - elseif !iscntrl(Char(c)) && plen < 128 + - write(s, c) + - end + - end + - return seekstart(s) + - end + - else + - function getpass(input::TTY, output::IO, prompt::AbstractString) + - (input === stdin && output === stdout) || throw(ArgumentError("getpass only works for stdin")) + - msg = string(prompt, ": ") + - unsafe_SecretBuffer!(ccall(:getpass, Cstring, (Cstring,), msg)) + - end + - end + - + - # allow new getpass methods to be defined if stdin has been + - # redirected to some custom stream, e.g. in IJulia. + - getpass(prompt::AbstractString) = getpass(stdin, stdout, prompt) + - + - """ + - prompt(message; default="") -> Union{String, Nothing} + - + - Displays the `message` then waits for user input. Input is terminated when a newline (\\n) + - is encountered or EOF (^D) character is entered on a blank line. If a `default` is provided + - then the user can enter just a newline character to select the `default`. + - + - See also `Base.getpass` and `Base.winprompt` for secure entry of passwords. + - """ + - function prompt(input::IO, output::IO, message::AbstractString; default::AbstractString="") + - msg = !isempty(default) ? "$message [$default]: " : "$message: " + - print(output, msg) + - uinput = readline(input, keep=true) + - isempty(uinput) && return nothing # Encountered an EOF + - uinput = chomp(uinput) + - isempty(uinput) ? default : uinput + - end + - + - # allow new prompt methods to be defined if stdin has been + - # redirected to some custom stream, e.g. in IJulia. + - prompt(message::AbstractString; default::AbstractString="") = prompt(stdin, stdout, message, default=default) + - + - # Windows authentication prompt + - if Sys.iswindows() + - struct CREDUI_INFO + - cbSize::UInt32 + - parent::Ptr{Cvoid} + - pszMessageText::Ptr{UInt16} + - pszCaptionText::Ptr{UInt16} + - banner::Ptr{Cvoid} + - end + - + - const CREDUIWIN_GENERIC = 0x0001 + - const CREDUIWIN_IN_CRED_ONLY = 0x0020 + - const CREDUIWIN_ENUMERATE_CURRENT_USER = 0x0200 + - + - const CRED_PACK_GENERIC_CREDENTIALS = 0x0004 + - + - const ERROR_SUCCESS = 0x0000 + - const ERROR_CANCELLED = 0x04c7 + - + - function winprompt(message, caption, default_username; prompt_username = true) + - # Step 1: Create an encrypted username/password bundle that will be used to set + - # the default username (in theory could also provide a default password) + - credbuf = Vector{UInt8}(undef, 1024) + - credbufsize = Ref{UInt32}(sizeof(credbuf)) + - succeeded = ccall((:CredPackAuthenticationBufferW, "credui.dll"), stdcall, Bool, + - (UInt32, Cwstring, Cwstring, Ptr{UInt8}, Ptr{UInt32}), + - CRED_PACK_GENERIC_CREDENTIALS, default_username, "", credbuf, credbufsize) + - @assert succeeded + - + - # Step 2: Create the actual dialog + - # 2.1: Set up the window + - messageArr = Base.cwstring(message) + - captionArr = Base.cwstring(caption) + - pfSave = Ref{Bool}(false) + - cred = Ref{CREDUI_INFO}(CREDUI_INFO(sizeof(CREDUI_INFO), C_NULL, pointer(messageArr), pointer(captionArr), C_NULL)) + - dwflags = CREDUIWIN_GENERIC | CREDUIWIN_ENUMERATE_CURRENT_USER + - if !prompt_username + - # Disable setting anything other than default_username + - dwflags |= CREDUIWIN_IN_CRED_ONLY + - end + - authPackage = Ref{Culong}(0) + - outbuf_data = Ref{Ptr{Cvoid}}(C_NULL) + - outbuf_size = Ref{Culong}(0) + - + - # 2.2: Do the actual request + - code = ccall((:CredUIPromptForWindowsCredentialsW, "credui.dll"), stdcall, UInt32, (Ptr{CREDUI_INFO}, UInt32, Ptr{Culong}, + - Ptr{Cvoid}, Culong, Ptr{Ptr{Cvoid}}, Ptr{Culong}, Ptr{Bool}, UInt32), cred, 0, authPackage, credbuf, credbufsize[], + - outbuf_data, outbuf_size, pfSave, dwflags) + - + - # 2.3: If that failed for any reason other than the user canceling, error out. + - # If the user canceled, just return nothing + - if code == ERROR_CANCELLED + - return nothing + - elseif code != ERROR_SUCCESS + - error(Base.Libc.FormatMessage(code)) + - end + - + - # Step 3: Convert encrypted credentials back to plain text + - passbuf = Vector{UInt16}(undef, 1024) + - passlen = Ref{UInt32}(length(passbuf)) + - usernamebuf = Vector{UInt16}(undef, 1024) + - usernamelen = Ref{UInt32}(length(usernamebuf)) + - # Need valid buffers for domain, even though we don't care + - dummybuf = Vector{UInt16}(undef, 1024) + - succeeded = ccall((:CredUnPackAuthenticationBufferW, "credui.dll"), Bool, + - (UInt32, Ptr{Cvoid}, UInt32, Ptr{UInt16}, Ptr{UInt32}, Ptr{UInt16}, Ptr{UInt32}, Ptr{UInt16}, Ptr{UInt32}), + - 0, outbuf_data[], outbuf_size[], usernamebuf, usernamelen, dummybuf, Ref{UInt32}(1024), passbuf, passlen) + - if !succeeded + - error(Base.Libc.FormatMessage()) + - end + - + - # Step 4: Free the encrypted buffer + - # ccall(:SecureZeroMemory, Ptr{Cvoid}, (Ptr{Cvoid}, Csize_t), outbuf_data[], outbuf_size[]) - not an actual function + - unsafe_securezero!(outbuf_data[], outbuf_size[]) + - ccall((:CoTaskMemFree, "ole32.dll"), Cvoid, (Ptr{Cvoid},), outbuf_data[]) + - + - # Done. + - passbuf_ = passbuf[1:passlen[]-1] + - result = (String(transcode(UInt8, usernamebuf[1:usernamelen[]-1])), + - SecretBuffer!(transcode(UInt8, passbuf_))) + - securezero!(passbuf_) + - securezero!(passbuf) + - + - return result + - end + - + - end + - + - unsafe_crc32c(a, n, crc) = ccall(:jl_crc32c, UInt32, (UInt32, Ptr{UInt8}, Csize_t), crc, a, n) + - + - _crc32c(a::Union{Array{UInt8},FastContiguousSubArray{UInt8,N,<:Array{UInt8}} where N}, crc::UInt32=0x00000000) = + - unsafe_crc32c(a, length(a) % Csize_t, crc) + - + - _crc32c(s::String, crc::UInt32=0x00000000) = unsafe_crc32c(s, sizeof(s) % Csize_t, crc) + - + - function _crc32c(io::IO, nb::Integer, crc::UInt32=0x00000000) + - nb < 0 && throw(ArgumentError("number of bytes to checksum must be ≥ 0")) + - # use block size 24576=8192*3, since that is the threshold for + - # 3-way parallel SIMD code in the underlying jl_crc32c C function. + - buf = Vector{UInt8}(undef, min(nb, 24576)) + - while !eof(io) && nb > 24576 + - n = readbytes!(io, buf) + - crc = unsafe_crc32c(buf, n, crc) + - nb -= n + - end + - return unsafe_crc32c(buf, readbytes!(io, buf, min(nb, length(buf))), crc) + - end + - _crc32c(io::IO, crc::UInt32=0x00000000) = _crc32c(io, typemax(Int64), crc) + - _crc32c(io::IOStream, crc::UInt32=0x00000000) = _crc32c(io, filesize(io)-position(io), crc) + - _crc32c(uuid::UUID, crc::UInt32=0x00000000) = + - ccall(:jl_crc32c, UInt32, (UInt32, Ref{UInt128}, Csize_t), crc, uuid.value, 16) + - + - """ + - @kwdef typedef + - + - This is a helper macro that automatically defines a keyword-based constructor for the type + - declared in the expression `typedef`, which must be a `struct` or `mutable struct` + - expression. The default argument is supplied by declaring fields of the form `field::T = + - default` or `field = default`. If no default is provided then the keyword argument becomes + - a required keyword argument in the resulting type constructor. + - + - # Examples + - ```jldoctest + - julia> Base.@kwdef struct Foo + - a::Int = 1 # specified default + - b::String # required keyword + - end + - Foo + - + - julia> Foo(b="hi") + - Foo(1, "hi") + - + - julia> Foo() + - ERROR: UndefKeywordError: keyword argument b not assigned + - Stacktrace: + - [...] + - ``` + - """ + - macro kwdef(expr) + - expr = macroexpand(__module__, expr) # to expand @static + - T = expr.args[2] + - params_ex = Expr(:parameters) + - call_ex = Expr(:call, T) + - _kwdef!(expr.args[3], params_ex, call_ex) + - ret = quote + - Base.@__doc__($(esc(expr))) + - end + - # Only define a constructor if the type has fields, otherwise we'll get a stack + - # overflow on construction + - if !isempty(params_ex.args) + - push!(ret.args, :($(esc(Expr(:call, T, params_ex))) = $(esc(call_ex)))) + - end + - ret + - end + - + - # @kwdef helper function + - # mutates arguments inplace + - function _kwdef!(blk, params_ex, call_ex) + - for i in eachindex(blk.args) + - ei = blk.args[i] + - if isa(ei, Symbol) + - push!(params_ex.args, ei) + - push!(call_ex.args, ei) + - elseif !isa(ei, Expr) + - continue + - elseif ei.head == :(=) + - # var::Typ = defexpr + - dec = ei.args[1] # var::Typ + - if isa(dec, Expr) && dec.head == :(::) + - var = dec.args[1] + - else + - var = dec + - end + - def = ei.args[2] # defexpr + - push!(params_ex.args, Expr(:kw, var, def)) + - push!(call_ex.args, var) + - blk.args[i] = dec + - elseif ei.head == :(::) + - dec = ei # var::Typ + - var = dec.args[1] # var + - push!(params_ex.args, var) + - push!(call_ex.args, var) + - elseif ei.head == :block + - # can arise with use of @static inside type decl + - _kwdef!(ei, params_ex, call_ex) + - end + - end + - blk + - end + - + - # testing + - + - """ + - Base.runtests(tests=["all"]; ncores=ceil(Int, Sys.CPU_THREADS / 2), + - exit_on_error=false, [seed]) + - + - Run the Julia unit tests listed in `tests`, which can be either a string or an array of + - strings, using `ncores` processors. If `exit_on_error` is `false`, when one test + - fails, all remaining tests in other files will still be run; they are otherwise discarded, + - when `exit_on_error == true`. + - If a seed is provided via the keyword argument, it is used to seed the + - global RNG in the context where the tests are run; otherwise the seed is chosen randomly. + - """ + - function runtests(tests = ["all"]; ncores = ceil(Int, Sys.CPU_THREADS / 2), + - exit_on_error=false, + - seed::Union{BitInteger,Nothing}=nothing) + - if isa(tests,AbstractString) + - tests = split(tests) + - end + - exit_on_error && push!(tests, "--exit-on-error") + - seed != nothing && push!(tests, "--seed=0x$(string(seed % UInt128, base=16))") # cast to UInt128 to avoid a minus sign + - ENV2 = copy(ENV) + - ENV2["JULIA_CPU_THREADS"] = "$ncores" + - try + - run(setenv(`$(julia_cmd()) $(joinpath(Sys.BINDIR::String, + - Base.DATAROOTDIR, "julia", "test", "runtests.jl")) $tests`, ENV2)) + - catch + - buf = PipeBuffer() + - Base.require(Base, :InteractiveUtils).versioninfo(buf) + - error("A test has failed. Please submit a bug report (https://github.com/JuliaLang/julia/issues)\n" * + - "including error messages above and the output of versioninfo():\n$(read(buf, String))") + - end + - end + - diff --git a/profiling/test.jl b/profiling/test.jl index 318dd100120721bc26ee669423eb21d709cfd7d6..6a55c22d12bb2ead435ce4e29f4e212dea1d5f1e 100644 --- a/profiling/test.jl +++ b/profiling/test.jl @@ -15,18 +15,17 @@ end f() - -@time f() -@profile f() -@allocated f() -x = @benchmark f() +#@time f() +#@profile f() +#@allocated f() +#x = @benchmark f() println() -println(x) -Profile.print(); +#println(x) +#Profile.print(); -#./julia-1.0.4/bin/julia --track-allocation=user +#./julia-1.0.4/bin/julia --track-allocation=user --code-coverage=user #include("test.jl") #ctrl d #emacs test.jl.mem diff --git a/profiling/test.jl.19966.cov b/profiling/test.jl.19966.cov new file mode 100644 index 0000000000000000000000000000000000000000..4d5bbdfb2cb317990671d9b8d5a38fac5397d8da --- /dev/null +++ b/profiling/test.jl.19966.cov @@ -0,0 +1,32 @@ + - using BenchmarkTools + - using Random + - using Profile + - + - + - function f() + 2818 lst = rand(50000) + 2818 for i in lst +140900000 if i > 0.99 + - s = "List entry $(i)\r" # The \r makes it so the terminal isn't filled +142307721 print(s) + - end + - end + - end + - + - f() + - + - @time f() + - @profile f() + - @allocated f() + - x = @benchmark f() + - println() + - println(x) + - Profile.print(); + - + - + - + - #./julia-1.0.4/bin/julia --track-allocation=user --code-coverage=user + - #include("test.jl") + - #ctrl d + - #emacs test.jl.mem + - diff --git a/profiling/test.jl.20032.cov b/profiling/test.jl.20032.cov new file mode 100644 index 0000000000000000000000000000000000000000..3b723411e27df7a8f089096b184f8d22adf506a4 --- /dev/null +++ b/profiling/test.jl.20032.cov @@ -0,0 +1,32 @@ + - using BenchmarkTools + - using Random + - using Profile + - + - + - function f() + 1 lst = rand(50000) + 1 for i in lst + 50000 if i > 0.99 + - s = "List entry $(i)\r" # The \r makes it so the terminal isn't filled + 50486 print(s) + - end + - end + - end + - + - f() + - + - #@time f() + - #@profile f() + - #@allocated f() + - #x = @benchmark f() + - println() + - #println(x) + - #Profile.print(); + - + - + - + - #./julia-1.0.4/bin/julia --track-allocation=user --code-coverage=user + - #include("test.jl") + - #ctrl d + - #emacs test.jl.mem + -