Skip to content

Commit 8910b75

Browse files
committed
[benchmark] Stop capitalizing function and variable names
1 parent 958733c commit 8910b75

File tree

172 files changed

+1913
-1921
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

172 files changed

+1913
-1921
lines changed

benchmark/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -296,10 +296,10 @@ public let YourTestName = BenchmarkInfo(
296296
tags: [.regression])
297297
298298
@inline(never)
299-
public func run_YourTestName(N: Int) {
299+
public func run_YourTestName(n: Int) {
300300
# Declare variables
301301
302-
for i in 1...N {
302+
for i in 1...n {
303303
# Perform work
304304
305305
# Verify work was done; break otherwise

benchmark/cxx-source/CreateObjects.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ public let CreateObjects = BenchmarkInfo(
2222
tags: [.validation, .bridging])
2323

2424
@inline(never)
25-
public func run_CreateObjects(_ N: Int) {
26-
for i in 0...(N * 10_000) {
25+
public func run_CreateObjects(_ n: Int) {
26+
for i in 0...(n * 10_000) {
2727
let x = Int32(i)
2828
let f = CxxLoadableIntWrapper(value: x)
2929
blackHole(f)

benchmark/multi-source/PrimsSplit/Prims.swift

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ class PriorityQueue {
7070
while (ind != 0) {
7171
let p = getParentIndex(ind)
7272
if heap[p].cost > c {
73-
Swap(p, with: ind)
73+
swap(p, with: ind)
7474
ind = p
7575
} else {
7676
break
@@ -83,7 +83,7 @@ class PriorityQueue {
8383
if (heap.isEmpty) {
8484
return nil
8585
}
86-
Swap(0, with:heap.count-1)
86+
swap(0, with:heap.count-1)
8787
let r = heap.removeLast()
8888
graphIndexToHeapIndexMap[r.to] = nil
8989
bubbleDown(0)
@@ -111,21 +111,21 @@ class PriorityQueue {
111111
if (heap[ind].cost <= heap[min].cost) {
112112
break
113113
}
114-
Swap(ind, with: min)
114+
swap(ind, with: min)
115115
ind = min
116116
}
117117
}
118118

119119
// Swaps elements I and J in the heap and correspondingly updates
120120
// graphIndexToHeapIndexMap.
121-
func Swap(_ i: Int, with j : Int) {
121+
func swap(_ i: Int, with j : Int) {
122122
if (i == j) {
123123
return
124124
}
125125
(heap[i], heap[j]) = (heap[j], heap[i])
126-
let (I, J) = (heap[i].to, heap[j].to)
127-
(graphIndexToHeapIndexMap[I], graphIndexToHeapIndexMap[J]) =
128-
(graphIndexToHeapIndexMap[J], graphIndexToHeapIndexMap[I])
126+
let (i2, j2) = (heap[i].to, heap[j].to)
127+
(graphIndexToHeapIndexMap[i2], graphIndexToHeapIndexMap[j2]) =
128+
(graphIndexToHeapIndexMap[j2], graphIndexToHeapIndexMap[i2])
129129
}
130130

131131
// Dumps the heap.
@@ -182,7 +182,7 @@ extension Edge : Hashable {
182182
}
183183
}
184184

185-
func Prims(_ graph : Array<GraphNode>, _ fun : (Int, Int) -> Double) -> Array<Int?> {
185+
func prims(_ graph : Array<GraphNode>, _ fun : (Int, Int) -> Double) -> Array<Int?> {
186186
var treeEdges = Array<Int?>(repeating:nil, count:graph.count)
187187

188188
let queue = PriorityQueue(Num:graph.count)

benchmark/multi-source/PrimsSplit/Prims_main.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ public let PrimsSplit = BenchmarkInfo(
1919
legacyFactor: 5)
2020

2121
@inline(never)
22-
public func run_PrimsSplit(_ N: Int) {
23-
for _ in 1...N {
22+
public func run_PrimsSplit(_ n: Int) {
23+
for _ in 1...n {
2424
let nodes : [Int] = [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,
2525
13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28,
2626
29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44,
@@ -547,7 +547,7 @@ public func run_PrimsSplit(_ N: Int) {
547547
}
548548

549549
// Find spanning tree
550-
let treeEdges = Prims(graph, { (start: Int, end: Int) in
550+
let treeEdges = prims(graph, { (start: Int, end: Int) in
551551
return map[Edge(start: start, end: end)]!
552552
})
553553

benchmark/scripts/Template.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,6 @@ public let {name} = [
1717
]
1818

1919
@inline(never)
20-
public func run_{name}(N: Int) {{
20+
public func run_{name}(n: Int) {{
2121
// TODO
2222
}}

benchmark/single-source/Ackermann.swift

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,30 +19,30 @@ public let Ackermann = BenchmarkInfo(
1919
runFunction: run_Ackermann,
2020
tags: [.algorithm])
2121

22-
func ackermann(_ M: Int, _ N : Int) -> Int {
23-
if (M == 0) { return N + 1 }
24-
if (N == 0) { return ackermann(M - 1, 1) }
25-
return ackermann(M - 1, ackermann(M, N - 1))
22+
func _ackermann(_ m: Int, _ n : Int) -> Int {
23+
if (m == 0) { return n + 1 }
24+
if (n == 0) { return ackermann(m - 1, 1) }
25+
return ackermann(m - 1, ackermann(m, n - 1))
2626
}
2727

2828
@inline(never)
29-
func Ackermann(_ M: Int, _ N : Int) -> Int {
29+
func ackermann(_ m: Int, _ n : Int) -> Int {
3030
// This if prevents optimizer from computing return value of Ackermann(3,9)
3131
// at compile time.
3232
if getFalse() { return 0 }
33-
if (M == 0) { return N + 1 }
34-
if (N == 0) { return ackermann(M - 1, 1) }
35-
return ackermann(M - 1, ackermann(M, N - 1))
33+
if (m == 0) { return n + 1 }
34+
if (n == 0) { return _ackermann(m - 1, 1) }
35+
return _ackermann(m - 1, _ackermann(m, n - 1))
3636
}
3737

3838
let ref_result = [5, 13, 29, 61, 125, 253, 509, 1021, 2045, 4093, 8189, 16381, 32765, 65533, 131069]
3939

4040
@inline(never)
41-
public func run_Ackermann(_ N: Int) {
41+
public func run_Ackermann(_ n: Int) {
4242
let (m, n) = (3, 6)
4343
var result = 0
44-
for _ in 1...N {
45-
result = Ackermann(m, n)
44+
for _ in 1...n {
45+
result = ackermann(m, n)
4646
if result != ref_result[n] {
4747
break
4848
}

benchmark/single-source/AngryPhonebook.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,9 @@ let words = [
7676
"Nicholas", "Eric", "Stephen", "Jacob", "Larry", "Frank"]
7777

7878
@inline(never)
79-
public func run_AngryPhonebook(_ N: Int) {
79+
public func run_AngryPhonebook(_ n: Int) {
8080
// Permute the names.
81-
for _ in 1...N {
81+
for _ in 1...n {
8282
for firstname in words {
8383
for lastname in words {
8484
_ = (firstname.uppercased(), lastname.lowercased())
@@ -132,10 +132,10 @@ let longArmenian = phonebook(armenian)
132132
let longCyrillic = phonebook(cyrillic)
133133

134134
@inline(never)
135-
public func angryPhonebook(_ N: Int, _ names: [String]) {
135+
public func angryPhonebook(_ n: Int, _ names: [String]) {
136136
assert(names.count == 20)
137137
// Permute the names.
138-
for _ in 1...N {
138+
for _ in 1...n {
139139
for firstname in names {
140140
for lastname in names {
141141
blackHole((firstname.uppercased(), lastname.lowercased()))
@@ -145,8 +145,8 @@ public func angryPhonebook(_ N: Int, _ names: [String]) {
145145
}
146146

147147
@inline(never)
148-
public func angryPhonebook(_ N: Int, precomposed names: String) {
149-
for _ in 1...N {
148+
public func angryPhonebook(_ n: Int, precomposed names: String) {
149+
for _ in 1...n {
150150
blackHole((names.uppercased(), names.lowercased()))
151151
}
152152
}

benchmark/single-source/AnyHashableWithAClass.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,9 @@ class TestHashableDerived4 : TestHashableDerived3 {}
5454
class TestHashableDerived5 : TestHashableDerived4 {}
5555

5656
@inline(never)
57-
public func run_AnyHashableWithAClass(_ N: Int) {
57+
public func run_AnyHashableWithAClass(_ n: Int) {
5858
let c = TestHashableDerived5(10)
59-
for _ in 0...(N*1000) {
59+
for _ in 0...(n*1000) {
6060
_ = AnyHashable(c)
6161
}
6262
}

benchmark/single-source/Array2D.swift

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,27 +23,27 @@ public let Array2D = BenchmarkInfo(
2323
let size = 256
2424

2525
var inputArray: [[Int]]! = {
26-
var A: [[Int]] = []
27-
A.reserveCapacity(size)
26+
var a: [[Int]] = []
27+
a.reserveCapacity(size)
2828
for _ in 0 ..< size {
29-
A.append(Array(0 ..< size))
29+
a.append(Array(0 ..< size))
3030
}
31-
return A
31+
return a
3232
}()
3333

3434
@inline(never)
35-
func modifyArray(_ A: inout [[Int]], _ N: Int) {
36-
for _ in 0..<N {
35+
func modifyArray(_ a: inout [[Int]], _ n: Int) {
36+
for _ in 0..<n {
3737
for i in 0 ..< size {
3838
for y in 0 ..< size {
39-
A[i][y] = A[i][y] + 1
40-
A[i][y] = A[i][y] - 1
39+
a[i][y] = a[i][y] + 1
40+
a[i][y] = a[i][y] - 1
4141
}
4242
}
4343
}
4444
}
4545

4646
@inline(never)
47-
public func run_Array2D(_ N: Int) {
48-
modifyArray(&inputArray, N)
47+
public func run_Array2D(_ n: Int) {
48+
modifyArray(&inputArray, n)
4949
}

0 commit comments

Comments
 (0)