Revision 76761961a0d04f610f695255c95804b076d566a4 authored by Tarn Yeong Ching on 15 July 2024, 16:46:25 UTC, committed by GitHub on 15 July 2024, 16:46:25 UTC
fix #54826 related performance test code: ```julia using BenchmarkTools using Base: IOError function checkmode(mode::Integer) if !(0 <= mode <= 511) throw(ArgumentError("Mode must be between 0 and 511 = 0o777")) end mode end function mkpath(path::AbstractString; mode::Integer = 0o777) dir = dirname(path) # stop recursion for `""`, `"/"`, or existed dir (path == dir || isdir(path)) && return path mkpath(dir, mode = checkmode(mode)) try # cases like `mkpath("x/")` will cause an error if `isdir(path)` is skipped # the error will not be rethrowed, but it may be slower, and thus we avoid it in advance isdir(path) || mkdir(path, mode = mode) catch err # If there is a problem with making the directory, but the directory # does in fact exist, then ignore the error. Else re-throw it. if !isa(err, IOError) || !isdir(path) rethrow() end end return path end function mkpath_2(path::AbstractString; mode::Integer = 0o777) dir = dirname(path) # stop recursion for `""` and `"/"` or existed dir (path == dir || isdir(path)) && return path mkpath_2(dir, mode = checkmode(mode)) try mkdir(path, mode = mode) catch err # If there is a problem with making the directory, but the directory # does in fact exist, then ignore the error. Else re-throw it. if !isa(err, IOError) || !isdir(path) rethrow() end end return path end versioninfo() display(@benchmark begin rm("A", recursive=true, force=true); mkpath("A/B/C/D/") end) display(@benchmark begin rm("A", recursive=true, force=true); mkpath_2("A/B/C/D/") end) ``` output: ``` Julia Version 1.10.4 Commit 48d4fd48430 (2024-06-04 10:41 UTC) Build Info: Official https://julialang.org/ release Platform Info: OS: macOS (x86_64-apple-darwin22.4.0) CPU: 16 × Intel(R) Core(TM) i9-9900K CPU @ 3.60GHz WORD_SIZE: 64 LIBM: libopenlibm LLVM: libLLVM-15.0.7 (ORCJIT, skylake) Threads: 1 default, 0 interactive, 1 GC (on 16 virtual cores) Environment: JULIA_EDITOR = code JULIA_NUM_THREADS = BenchmarkTools.Trial: 8683 samples with 1 evaluation. Range (min … max): 473.972 μs … 18.867 ms ┊ GC (min … max): 0.00% … 0.00% Time (median): 519.704 μs ┊ GC (median): 0.00% Time (mean ± σ): 571.261 μs ± 378.851 μs ┊ GC (mean ± σ): 0.00% ± 0.00% ▂█▇▄▁ ▃███████▇▅▄▄▃▃▃▂▂▂▂▂▂▂▂▂▂▂▂▂▂▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁ ▂ 474 μs Histogram: frequency by time 961 μs < Memory estimate: 5.98 KiB, allocs estimate: 65. BenchmarkTools.Trial: 6531 samples with 1 evaluation. Range (min … max): 588.122 μs … 17.449 ms ┊ GC (min … max): 0.00% … 0.00% Time (median): 660.071 μs ┊ GC (median): 0.00% Time (mean ± σ): 760.333 μs ± 615.759 μs ┊ GC (mean ± σ): 0.00% ± 0.00% ██▆▄▃▁▁ ▁ ██████████▆▇█▇▆▆▅▅▅▄▁▄▁▄▄▃▄▃▁▃▃▁▃▁▁▁▄▁▁▁▁▁▁▁▃▃▁▁▁▃▁▁▃▁▁▁▁▅▅▄▇ █ 588 μs Histogram: log(frequency) by time 4.2 ms < Memory estimate: 5.63 KiB, allocs estimate: 72. ```
1 parent b88f64f
.clang-format
Language: Cpp
Standard: Cpp11
AccessModifierOffset: -4
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: false
AlignConsecutiveDeclarations: false
AlignConsecutiveMacros: false
AlignEscapedNewlines: Left
AlignOperands: true
AlignTrailingComments: false
AllowAllArgumentsOnNextLine: true
AllowAllConstructorInitializersOnNextLine: true
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortBlocksOnASingleLine: Never
AllowShortCaseLabelsOnASingleLine: true
AllowShortFunctionsOnASingleLine: Inline
AllowShortIfStatementsOnASingleLine: Never
AllowShortLambdasOnASingleLine: All
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: true
BinPackArguments: true
BinPackParameters: true
BreakBeforeBinaryOperators: None
BreakBeforeBraces: Stroustrup
BreakBeforeInheritanceComma: false
BreakBeforeTernaryOperators: false
BreakConstructorInitializers: BeforeColon
BreakConstructorInitializersBeforeComma: false
BreakInheritanceList: BeforeColon
BreakStringLiterals: false
ColumnLimit: 92
CommentPragmas: '^ IWYU pragma:'
CompactNamespaces: false
ConstructorInitializerAllOnOneLineOrOnePerLine: true
ConstructorInitializerIndentWidth: 2
ContinuationIndentWidth: 4
Cpp11BracedListStyle: true
DeriveLineEnding: true
DerivePointerAlignment: false
DisableFormat: false
ExperimentalAutoDetectBinPacking: false
FixNamespaceComments: false
IncludeBlocks: Preserve
IncludeCategories:
- Regex: '^(<|"(llvm|llvm-c|clang|clang-c)/)'
Priority: 2
- Regex: '^<.*'
Priority: 3
- Regex: '.*'
Priority: 1
IncludeIsMainSourceRegex: ''
IndentCaseLabels: false
IndentGotoLabels: false
IndentPPDirectives: None
IndentWidth: 4
IndentWrappedFunctionNames: false
KeepEmptyLinesAtTheStartOfBlocks: false
MacroBlockBegin: ''
MacroBlockEnd: ''
MaxEmptyLinesToKeep: 2
NamespaceIndentation: None
PenaltyBreakAssignment: 2
PenaltyBreakBeforeFirstCallParameter: 30
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
PenaltyBreakString: 1000
PenaltyBreakTemplateDeclaration: 10
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 60
PointerAlignment: Right
ReflowComments: true
SortIncludes: true
SortUsingDeclarations: true
SpaceAfterCStyleCast: false
SpaceAfterLogicalNot: false
SpaceAfterTemplateKeyword: false
SpaceBeforeAssignmentOperators: true
SpaceBeforeCpp11BracedList: false
SpaceBeforeCtorInitializerColon: true
SpaceBeforeInheritanceColon: true
SpaceBeforeParens: ControlStatements
SpaceBeforeRangeBasedForLoopColon: true
SpaceBeforeSquareBrackets: false
SpaceInEmptyBlock: false
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
SpacesInAngles: false
SpacesInCStyleCastParentheses: false
SpacesInConditionalStatement: false
SpacesInContainerLiterals: true
SpacesInParentheses: false
SpacesInSquareBrackets: false
TabWidth: 8
UseCRLF: true
UseTab: Never
ForEachMacros:
- JL_TRY
- JL_CATCH
StatementMacros:
- bi_fintrinsic
- bi_iintrinsic_fast
- bi_intrinsic_ctype
- bool_fintrinsic
- bool_iintrinsic_fast
- bool_intrinsic_ctype
- checked_intrinsic_ctype
- cvt_iintrinsic
- fpiseq_n
- ter_fintrinsic
- ter_intrinsic_ctype
- un_fintrinsic
- un_fintrinsic_withtype
- un_iintrinsic_ctype
- uu_iintrinsic_ctype
Computing file changes ...