<commit_before>//===--- DictionarySwap.swift ---------------------------------------------===//
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See https://swift.org/LICENSE.txt for license information
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===----------------------------------------------------------------------===//

// Dictionary element swapping benchmark
// rdar://problem/19804127
import TestsUtils

let size = 100
let numberMap = Dictionary(uniqueKeysWithValues: zip(1...size, 1...size))
let boxedNums = (1...size).lazy.map { Box($0) }
let boxedNumMap = Dictionary(uniqueKeysWithValues: zip(boxedNums, boxedNums))

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

public let DictionarySwap = [
  BenchmarkInfo(name: "DictionarySwap",
    runFunction: swap, tags: t, legacyFactor: 4),
  BenchmarkInfo(name: "DictionarySwapOfObjects",
    runFunction: swapObjects, tags: t, legacyFactor: 40),
  BenchmarkInfo(name: "DictionarySwapAt",
    runFunction: swapAt, tags: t, legacyFactor: 4),
  BenchmarkInfo(name: "DictionarySwapAtOfObjects",
    runFunction: swapAtObjects, tags: t, legacyFactor: 10),
]

// Return true if correctly swapped, false otherwise
func swappedCorrectly(_ swapped: Bool, _ p25: Int, _ p75: Int) -> Bool {
    return swapped && (p25 == 75 && p75 == 25) ||
          !swapped && (p25 == 25 && p75 == 75)
}

class Box<T : Hashable> : Hashable {
  var value: T

  init(_ v: T) {
    value = v<commit_msg>[benchmark] Fine tune legacyFactor some more<commit_after>//===--- DictionarySwap.swift ---------------------------------------------===//
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See https://swift.org/LICENSE.txt for license information
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===----------------------------------------------------------------------===//

// Dictionary element swapping benchmark
// rdar://problem/19804127
import TestsUtils

let size = 100
let numberMap = Dictionary(uniqueKeysWithValues: zip(1...size, 1...size))
let boxedNums = (1...size).lazy.map { Box($0) }
let boxedNumMap = Dictionary(uniqueKeysWithValues: zip(boxedNums, boxedNums))

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

public let DictionarySwap = [
  BenchmarkInfo(name: "DictionarySwap",
    runFunction: swap, tags: t, legacyFactor: 4),
  BenchmarkInfo(name: "DictionarySwapOfObjects",
    runFunction: swapObjects, tags: t, legacyFactor: 40),
  BenchmarkInfo(name: "DictionarySwapAt",
    runFunction: swapAt, tags: t, legacyFactor: 4),
  BenchmarkInfo(name: "DictionarySwapAtOfObjects",
    runFunction: swapAtObjects, tags: t, legacyFactor: 11),
]

// Return true if correctly swapped, false otherwise
func swappedCorrectly(_ swapped: Bool, _ p25: Int, _ p75: Int) -> Bool {
    return swapped && (p25 == 75 && p75 == 25) ||
          !swapped && (p25 == 25 && p75 == 75)
}

class Box<T : Hashable> : Hashable {
  var value: T

  init(_ v: T) {
    value = v
{'fraction_non_alphanumeric': 0.19790732436472347, 'fraction_numerical': 0.030493273542600896, 'mean_word_length': 2.863741339491917, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4729746', 'n_tokens_mistral': 1082, 'n_tokens_neox': 980, 'n_words': 306}