<commit_before>//===--- Chars.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
//
//===----------------------------------------------------------------------===//

// This test tests the performance of ASCII Character comparison.
import TestsUtils

public let Chars = BenchmarkInfo(
  name: "Chars",
  runFunction: run_Chars,
  tags: [.validation, .api, .String],
  setUpFunction: { blackHole(alphabetInput) })

var alphabetInput: [Character] = [
    "A", "B", "C", "D", "E", "F", "G",
    "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R",
    "S", "T", "U",
    "V", "W", "X", "Y", "Z", "/", "f", "Z", "z", "6", "7", "C", "j", "f", "9",
    "g", "g", "I", "J", "K", "c", "x", "i", ".",
    "2", "a", "t", "i", "o", "e", "q", "n", "X", "Y", "Z", "?", "m", "Z", ","
    ]

@inline(never)
public func run_Chars(_ N: Int) {
  // Permute some characters.
  let alphabet: [Character] = alphabetInput

  for _ in 0..<N {
    for firstChar in alphabet {
      for middleChar in alphabet {
        for lastChar in alphabet {
          _ = ((firstChar == middleChar) != (middleChar < lastChar))
        }
      }
    }
  }
}<commit_msg>benchmarks: fix the Chars benchmark by adding blackHoles and testing all possible Char comparisons<commit_after>//===--- Chars.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
//
//===----------------------------------------------------------------------===//

// This test tests the performance of ASCII Character comparison.
import TestsUtils

public let Chars = BenchmarkInfo(
  name: "Chars2",
  runFunction: run_Chars,
  tags: [.validation, .api, .String],
  setUpFunction: { blackHole(alphabetInput) })

var alphabetInput: [Character] = [
    "A", "B", "C", "D", "E", "F", "G",
    "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R",
    "S", "T", "U",
    "V", "W", "X", "Y", "Z", "/", "f", "Z", "z", "6", "7", "C", "j", "f", "9",
    "g", "g", "I", "J", "K", "c", "x", "i", ".",
    "2", "a", "t", "i", "o", "e", "q", "n", "X", "Y", "Z", "?", "m", "Z", ","
    ]

@inline(never)
public func run_Chars(_ N: Int) {
  // Permute some characters.
  let alphabet: [Character] = alphabetInput

  for _ in 0..<50*N {
    for firstChar in alphabet {
      for lastChar in alphabet {
        blackHole(firstChar < lastChar)
        blackHole(firstChar == lastChar)
        blackHole(firstChar > lastChar)
        blackHole(firstChar <= lastChar)
        blackHole(firstChar >= lastChar)
      }
    }
  }
}
{'fraction_non_alphanumeric': 0.278441231929604, 'fraction_numerical': 0.010370835952231301, 'mean_word_length': 2.2281947261663286, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 5, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3086002', 'n_tokens_mistral': 1102, 'n_tokens_neox': 1038, 'n_words': 341}