Skip to content

Python3 compatibility for Benchmarks #33039

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
Jul 22, 2020
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
284 changes: 142 additions & 142 deletions benchmark/single-source/CharacterProperties.swift

Large diffs are not rendered by default.

44 changes: 22 additions & 22 deletions benchmark/single-source/CharacterProperties.swift.gyb
Original file line number Diff line number Diff line change
Expand Up @@ -52,27 +52,27 @@ extension Character {
var firstScalar: UnicodeScalar { return unicodeScalars.first! }
}

% Properties = { "Alphanumeric": "alphanumerics", \
% "Capitalized": "capitalizedLetters", \
% "Control": "controlCharacters", \
% "Decimal": "decimalDigits", \
% "Letter": "letters", \
% "Lowercase": "lowercaseLetters", \
% "Uppercase": "uppercaseLetters", \
% "Newline": "newlines", \
% "Whitespace": "whitespaces", \
% "Punctuation": "punctuationCharacters" \
% }
% Properties = [ ( "Alphanumeric", "alphanumerics"),
% ( "Capitalized", "capitalizedLetters"),
% ( "Control", "controlCharacters"),
% ( "Decimal", "decimalDigits"),
% ( "Letter", "letters"),
% ( "Lowercase", "lowercaseLetters"),
% ( "Uppercase", "uppercaseLetters"),
% ( "Newline", "newlines"),
% ( "Whitespace", "whitespaces"),
% ( "Punctuation", "punctuationCharacters")
% ]

// Fetch the CharacterSet for every call
% for Property, Set in Properties.items():
% for Property, Set in Properties:
func is${Property}(_ c: Character) -> Bool {
return CharacterSet.${Set}.contains(c.firstScalar)
}
% end

// Stash the set
% for Property, Set in Properties.items():
% for Property, Set in Properties:
let ${Set} = CharacterSet.${Set}
func is${Property}Stashed(_ c: Character) -> Bool {
return ${Set}.contains(c.firstScalar)
Expand All @@ -81,13 +81,13 @@ func is${Property}Stashed(_ c: Character) -> Bool {

func setupStash() {
blackHole(workload)
% for Property, Set in Properties.items():
% for Property, Set in Properties:
blackHole(${Set})
% end
}

// Memoize the stashed set
% for Property, Set in Properties.items():
% for Property, Set in Properties:
var ${Set}Memo = Set<UInt32>()
func is${Property}StashedMemo(_ c: Character) -> Bool {
let scalar = c.firstScalar
Expand All @@ -102,7 +102,7 @@ func is${Property}StashedMemo(_ c: Character) -> Bool {

func setupMemo() {
blackHole(workload)
% for Property, Set in Properties.items():
% for Property, Set in Properties:
blackHole(${Set}Memo)
% end
}
Expand Down Expand Up @@ -130,7 +130,7 @@ func precompute(_ charSet: CharacterSet, capacity: Int) -> Set<UInt32> {
capitalizedLetters=31
)
}%
% for Property, Set in Properties.items():
% for Property, Set in Properties:
var ${Set}Precomputed: Set<UInt32> =
precompute(${Set}, capacity: ${precomputed_capacity[Set]})
func is${Property}Precomputed(_ c: Character) -> Bool {
Expand All @@ -140,7 +140,7 @@ func is${Property}Precomputed(_ c: Character) -> Bool {

func setupPrecomputed() {
blackHole(workload)
% for Property, Set in Properties.items():
% for Property, Set in Properties:
blackHole(${Set}Precomputed)
%#// print("${Set}: \(${Set}Precomputed.count)")
% end
Expand Down Expand Up @@ -171,7 +171,7 @@ let workload = """
public func run_CharacterPropertiesFetch(_ N: Int) {
for _ in 1...N {
for c in workload {
% for Property, Set in Properties.items():
% for Property, Set in Properties:
blackHole(is${Property}(c))
% end
}
Expand All @@ -182,7 +182,7 @@ public func run_CharacterPropertiesFetch(_ N: Int) {
public func run_CharacterPropertiesStashed(_ N: Int) {
for _ in 1...N {
for c in workload {
% for Property, Set in Properties.items():
% for Property, Set in Properties:
blackHole(is${Property}Stashed(c))
% end
}
Expand All @@ -193,7 +193,7 @@ public func run_CharacterPropertiesStashed(_ N: Int) {
public func run_CharacterPropertiesStashedMemo(_ N: Int) {
for _ in 1...N {
for c in workload {
% for Property, Set in Properties.items():
% for Property, Set in Properties:
blackHole(is${Property}StashedMemo(c))
% end
}
Expand All @@ -204,7 +204,7 @@ public func run_CharacterPropertiesStashedMemo(_ N: Int) {
public func run_CharacterPropertiesPrecomputed(_ N: Int) {
for _ in 1...N {
for c in workload {
% for Property, Set in Properties.items():
% for Property, Set in Properties:
blackHole(is${Property}Precomputed(c))
% end
}
Expand Down
2 changes: 1 addition & 1 deletion benchmark/single-source/DropFirst.swift.gyb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ Sequences = [
]
def lazy (NameExpr) : return (NameExpr[0] + 'Lazy', '(' + NameExpr[1] + ').lazy')

Sequences = Sequences + map(lazy, Sequences)
Sequences = Sequences + list(map(lazy, Sequences))
}%

public let DropFirst = [
Expand Down
2 changes: 1 addition & 1 deletion benchmark/single-source/DropLast.swift.gyb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ Sequences = [
]
def lazy (NameExpr) : return (NameExpr[0] + 'Lazy', '(' + NameExpr[1] + ').lazy')

Sequences = Sequences + map(lazy, Sequences)
Sequences = Sequences + list(map(lazy, Sequences))
}%

public let DropLast = [
Expand Down
2 changes: 1 addition & 1 deletion benchmark/single-source/DropWhile.swift.gyb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ Sequences = [
]
def lazy (NameExpr) : return (NameExpr[0] + 'Lazy', '(' + NameExpr[1] + ').lazy')

Sequences = Sequences + map(lazy, Sequences)
Sequences = Sequences + list(map(lazy, Sequences))
}%

public let DropWhile = [
Expand Down
4 changes: 2 additions & 2 deletions benchmark/single-source/ExistentialPerformance.swift.gyb
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ func next(_ x: inout Int, upto mod: Int) {
x = (x + 1) % (mod + 1)
}

% for (V, i) in [(v, int(filter(str.isdigit, v))) for v in Vals]:
% for (V, i) in [(v, int(''.join(filter(str.isdigit, v)))) for v in Vals]:
struct ${V} : Existential {${
''.join(['\n var f{0}: Int = {1}'.format(vi, v)
for (vi, v) in Vars[0:i]]) +
Expand Down Expand Up @@ -208,7 +208,7 @@ class Klazz { // body same as Val2
}
}

% for (V, i) in [(v, int(filter(str.isdigit, v))) for v in Refs]:
% for (V, i) in [(v, int(''.join(filter(str.isdigit, v)))) for v in Refs]:
struct ${V} : Existential {
${'\n '.join([('var f{0}: Klazz = Klazz()'.format(vi) if vi < 3 else
'var f3: Int = 0') for (vi, _) in Vars[0:i]])}
Expand Down
2 changes: 1 addition & 1 deletion benchmark/single-source/Prefix.swift.gyb
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ Sequences = [
]
def lazy (NameExpr) : return (NameExpr[0] + 'Lazy', '(' + NameExpr[1] + ').lazy')

Sequences = Sequences + map(lazy, Sequences)
Sequences = Sequences + list(map(lazy, Sequences))
}%

public let Prefix = [
Expand Down
2 changes: 1 addition & 1 deletion benchmark/single-source/PrefixWhile.swift.gyb
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ Sequences = [
]
def lazy (NameExpr) : return (NameExpr[0] + 'Lazy', '(' + NameExpr[1] + ').lazy')

Sequences = Sequences + map(lazy, Sequences)
Sequences = Sequences + list(map(lazy, Sequences))
}%

public let PrefixWhile = [
Expand Down
2 changes: 1 addition & 1 deletion benchmark/single-source/Suffix.swift.gyb
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ Sequences = [
]
def lazy (NameExpr) : return (NameExpr[0] + 'Lazy', '(' + NameExpr[1] + ').lazy')

Sequences = Sequences + map(lazy, Sequences)
Sequences = Sequences + list(map(lazy, Sequences))
}%

public let Suffix = [
Expand Down