Skip to content

[benchmark] Move fake autoreleasepool to TestUtils #22707

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 20, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 0 additions & 12 deletions benchmark/single-source/Codable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -107,18 +107,6 @@ public func setup_json() {
JSONTester = CodablePerfTester(encoder: JSONEncoder(), decoder: JSONDecoder())
}

#if !_runtime(_ObjC)
// If we do not have an objc-runtime, then we do not have a definition for
// autoreleasepool. Add in our own fake autoclosure for it that is inline
// always. That should be able to be eaten through by the optimizer no problem.
@inline(__always)
public func autoreleasepool<Result>(
invoking body: () throws -> Result
) rethrows -> Result {
return try body()
}
#endif

@inline(never)
public func run_JSONPerfEncode(_ N: Int) {
autoreleasepool {
Expand Down
13 changes: 13 additions & 0 deletions benchmark/utils/TestsUtils.swift
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,19 @@ public func CheckResults(
}
}

#if !_runtime(_ObjC)
// If we do not have an objc-runtime, then we do not have a definition for
// autoreleasepool. Add in our own fake autoclosure for it that is inline
// always. That should be able to be eaten through by the optimizer no problem.
@inlinable // FIXME(inline-always)
@inline(__always)
public func autoreleasepool<Result>(
invoking body: () throws -> Result
) rethrows -> Result {
return try body()
}
#endif

public func False() -> Bool { return false }

/// This is a dummy protocol to test the speed of our protocol dispatch.
Expand Down