Skip to content

[benchmark] Janitor Duty: Final Sweep #24677

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 2 commits into from
Apr 15, 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
33 changes: 24 additions & 9 deletions benchmark/single-source/InsertCharacter.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//===--- InsertCharacter.swift ------------------------------------------------===//
//===--- InsertCharacter.swift --------------------------------------------===//
//
// This source file is part of the Swift.org open source project
//
Expand All @@ -12,13 +12,27 @@

import TestsUtils

let t: [BenchmarkCategory] = [.validation, .api, .String]

public let InsertCharacter = [
BenchmarkInfo(name: "InsertCharacterEndIndex", runFunction: run_InsertCharacterEndIndex, tags: [.validation, .api], setUpFunction: buildWorkload),
BenchmarkInfo(name: "InsertCharacterTowardsEndIndex", runFunction: run_InsertCharacterTowardsEndIndex, tags: [.validation, .api], setUpFunction: buildWorkload),
BenchmarkInfo(name: "InsertCharacterStartIndex", runFunction: run_InsertCharacterStartIndex, tags: [.validation, .api], setUpFunction: buildWorkload),
BenchmarkInfo(name: "InsertCharacterEndIndexNonASCII", runFunction: run_InsertCharacterEndIndexNonASCII, tags: [.validation, .api], setUpFunction: buildWorkload),
BenchmarkInfo(name: "InsertCharacterTowardsEndIndexNonASCII", runFunction: run_InsertCharacterTowardsEndIndexNonASCII, tags: [.validation, .api], setUpFunction: buildWorkload),
BenchmarkInfo(name: "InsertCharacterStartIndexNonASCII", runFunction: run_InsertCharacterStartIndexNonASCII, tags: [.validation, .api], setUpFunction: buildWorkload)
BenchmarkInfo(name: "InsertCharacterEndIndex",
runFunction: run_InsertCharacterEndIndex, tags: t,
setUpFunction: buildWorkload),
BenchmarkInfo(name: "InsertCharacterTowardsEndIndex",
runFunction: run_InsertCharacterTowardsEndIndex, tags: t,
setUpFunction: buildWorkload),
BenchmarkInfo(name: "InsertCharacterStartIndex",
runFunction: run_InsertCharacterStartIndex, tags: t,
setUpFunction: buildWorkload, legacyFactor: 5),
BenchmarkInfo(name: "InsertCharacterEndIndexNonASCII",
runFunction: run_InsertCharacterEndIndexNonASCII, tags: t,
setUpFunction: buildWorkload),
BenchmarkInfo(name: "InsertCharacterTowardsEndIndexNonASCII",
runFunction: run_InsertCharacterTowardsEndIndexNonASCII, tags: t,
setUpFunction: buildWorkload),
BenchmarkInfo(name: "InsertCharacterStartIndexNonASCII",
runFunction: run_InsertCharacterStartIndexNonASCII, tags: t,
setUpFunction: buildWorkload)
]

let str = String(repeating: "A very long ASCII string.", count: 200)
Expand Down Expand Up @@ -76,7 +90,8 @@ func run_InsertCharacterEndIndexNonASCII(_ N: Int) {
// Insert at start index

@inline(__always)
func insertAtStartIndex(_ c: Character, in string: String, count: Int, insertions: Int) {
func insertAtStartIndex(
_ c: Character, in string: String, count: Int, insertions: Int) {
var workload = str
for _ in 0..<count {
for _ in 0..<insertions {
Expand All @@ -89,7 +104,7 @@ func insertAtStartIndex(_ c: Character, in string: String, count: Int, insertion

@inline(never)
func run_InsertCharacterStartIndex(_ N: Int) {
insertAtStartIndex("w", in: str, count: N * 75, insertions: 50)
insertAtStartIndex("w", in: str, count: N * 15, insertions: 50)
}

@inline(never)
Expand Down
8 changes: 4 additions & 4 deletions benchmark/single-source/ReduceInto.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ import Foundation
public let ReduceInto = [
BenchmarkInfo(name: "FilterEvenUsingReduce", runFunction: run_FilterEvenUsingReduce, tags: [.validation, .api], legacyFactor: 10),
BenchmarkInfo(name: "FilterEvenUsingReduceInto", runFunction: run_FilterEvenUsingReduceInto, tags: [.validation, .api]),
BenchmarkInfo(name: "FrequenciesUsingReduce", runFunction: run_FrequenciesUsingReduce, tags: [.validation, .api]),
BenchmarkInfo(name: "FrequenciesUsingReduceInto", runFunction: run_FrequenciesUsingReduceInto, tags: [.validation, .api]),
BenchmarkInfo(name: "FrequenciesUsingReduce", runFunction: run_FrequenciesUsingReduce, tags: [.validation, .api], legacyFactor: 10),
BenchmarkInfo(name: "FrequenciesUsingReduceInto", runFunction: run_FrequenciesUsingReduceInto, tags: [.validation, .api], legacyFactor: 10),
BenchmarkInfo(name: "SumUsingReduce", runFunction: run_SumUsingReduce, tags: [.validation, .api]),
BenchmarkInfo(name: "SumUsingReduceInto", runFunction: run_SumUsingReduceInto, tags: [.validation, .api]),
]
Expand Down Expand Up @@ -93,7 +93,7 @@ public func run_FrequenciesUsingReduce(_ N: Int) {
let s = "thequickbrownfoxjumpsoverthelazydogusingasmanycharacteraspossible123456789"

var c = 0
for _ in 1...N*100 {
for _ in 1...N*10 {
let a = s.reduce([:]) {
(acc: [Character: Int], c: Character) -> [Character: Int] in
var d = acc
Expand All @@ -110,7 +110,7 @@ public func run_FrequenciesUsingReduceInto(_ N: Int) {
let s = "thequickbrownfoxjumpsoverthelazydogusingasmanycharacteraspossible123456789"

var c = 0
for _ in 1...N*100 {
for _ in 1...N*10 {
let a = s.reduce(into: [:]) {
(acc: inout [Character: Int], c: Character) in
acc[c, default: 0] += 1
Expand Down