 
 func benchmark_AppendData(_ N: Int, _ lhs: Data, _ rhs: Data) {
     var data = lhs
-    for _ in 1...10000*N {
+    for _ in 0..<10000*N {
         data = lhs
         data.append(rhs)
     }
 }
 
 @inline(never)
-public func run_Subscript(_ N: Int) {
-    let data = medium
-    let index = 521
-    for _ in 1...10000*N {
+public func run_SubscriptSmall(_ N: Int) {
+    let data = sampleData(.small)
+    let index = 1
+    for _ in 0..<10000*N {
         // Ensure that the compiler does not optimize away this call
         blackHole(data[index])
     }
 }
 
 @inline(never)
-public func run_Count(_ N: Int) {
-    let data = medium
-    for _ in 1...10000*N {
+public func run_SubscriptMedium(_ N: Int) {
+    let data = sampleData(.medium)
+    let index = 521
+    for _ in 0..<10000*N {
+        // Ensure that the compiler does not optimize away this call
+        blackHole(data[index])
+    }
+}
+
+@inline(never)
+public func run_SubscriptLarge(_ N: Int) {
+    let data = sampleData(.veryLarge)
+    let index = 521
+    for _ in 0..<10000*N {
+        // Ensure that the compiler does not optimize away this call
+        blackHole(data[index])
+    }
+}
+
+@inline(never)
+public func run_CountSmall(_ N: Int) {
+    let data = sampleData(.small)
+    for _ in 0..<10000*N {
         // Ensure that the compiler does not optimize away this call
         blackHole(data.count)
     }
 }
 
 @inline(never)
-public func run_SetCount(_ N: Int) {
-    let data = medium
+public func run_CountMedium(_ N: Int) {
+    let data = sampleData(.medium)
+    for _ in 0..<10000*N {
+        // Ensure that the compiler does not optimize away this call
+        blackHole(data.count)
+    }
+}
+
+@inline(never)
+public func run_CountLarge(_ N: Int) {
+    let data = sampleData(.veryLarge)
+    for _ in 0..<10000*N {
+        // Ensure that the compiler does not optimize away this call
+        blackHole(data.count)
+    }
+}
+
+@inline(never)
+public func run_SetCountSmall(_ N: Int) {
+    var data = sampleData(.small)
+    let count = data.count + 3
+    let orig = data.count
+    for _ in 0..<10000*N {
+        data.count = count
+        data.count = orig
+    }
+}
+
+@inline(never)
+public func run_SetCountMedium(_ N: Int) {
+    var data = sampleData(.medium)
     let count = data.count + 100
-    var otherData = data
     let orig = data.count
-    for _ in 1...10000*N {
-        otherData.count = count
-        otherData.count = orig
-    }
-}
-
-@inline(never)
-public func run_AccessBytes(_ N: Int) {
-    let data = medium
+    for _ in 0..<10000*N {
+        data.count = count
+        data.count = orig
+    }
+}
+
+@inline(never)
+public func run_SetCountLarge(_ N: Int) {
+    var data = sampleData(.large)
+    let count = data.count + 100
+    let orig = data.count
+    for _ in 0..<10000*N {
+        data.count = count
+        data.count = orig
+    }
+}
+
+@inline(never)
+public func run_AccessBytesSmall(_ N: Int) {
+    let data = sampleData(.small)
     benchmark_AccessBytes(N, data)
 }
 
-@inline(never)
-public func run_MutateBytes(_ N: Int) {
-    let data = medium
+
+@inline(never)
+public func run_AccessBytesMedium(_ N: Int) {
+    let data = sampleData(.medium)
+    benchmark_AccessBytes(N, data)
+}
+
+@inline(never)
+public func run_AccessBytesLarge(_ N: Int) {
+    let data = sampleData(.veryLarge)
+    benchmark_AccessBytes(N, data)
+}
+
+@inline(never)
+public func run_MutateBytesSmall(_ N: Int) {
+    let data = sampleData(.small)
     benchmark_MutateBytes(N, data)
 }
 
 @inline(never)
-public func run_CopyBytes(_ N: Int) {
-    let data = medium
+public func run_MutateBytesMedium(_ N: Int) {
+    let data = sampleData(.medium)
+    benchmark_MutateBytes(N, data)
+}
+
+@inline(never)
+public func run_MutateBytesLarge(_ N: Int) {
+    let data = sampleData(.veryLarge)
+    benchmark_MutateBytes(N, data)
+}
+
+@inline(never)
+public func run_CopyBytesSmall(_ N: Int) {
+    let data = sampleData(.small)
     benchmark_CopyBytes(N, data)
 }
 
 @inline(never)
-public func run_AppendBytes(_ N: Int) {
-    let data = medium
+public func run_CopyBytesMedium(_ N: Int) {
+    let data = sampleData(.medium)
+    benchmark_CopyBytes(N, data)
+}
+
+@inline(never)
+public func run_CopyBytesLarge(_ N: Int) {
+    let data = sampleData(.large)
+    benchmark_CopyBytes(N, data)
+}
+
+@inline(never)
+public func run_AppendBytesSmall(_ N: Int) {
+    let data = sampleData(.small)
+    benchmark_AppendBytes(N, 3, data)
+}
+
+@inline(never)
+public func run_AppendBytesMedium(_ N: Int) {
+    let data = sampleData(.medium)
     benchmark_AppendBytes(N, 809, data)
 }
 
 @inline(never)
+public func run_AppendBytesLarge(_ N: Int) {
+    let data = sampleData(.veryLarge)
+    benchmark_AppendBytes(N, 809, data)
+}
+
+@inline(never)
 public func run_AppendArray(_ N: Int) {
-    let data = medium
+    let data = sampleData(.medium)
     benchmark_AppendArray(N, 809, data)
 }
 
 @inline(never)
 public func run_Reset(_ N: Int) {
-    let data = medium
+    let data = sampleData(.medium)
     benchmark_Reset(N, 431..<809, data)
 }
 
 @inline(never)
 public func run_ReplaceSmall(_ N: Int) {
-    let data = medium
-    let replacement = small
+    let data = sampleData(.medium)
+    let replacement = sampleData(.small)
     benchmark_Replace(N, 431..<809, data, replacement)
 }
 
 @inline(never)
 public func run_ReplaceMedium(_ N: Int) {
-    let data = medium
-    let replacement = medium
+    let data = sampleData(.medium)
+    let replacement = sampleData(.medium)
     benchmark_Replace(N, 431..<809, data, replacement)
 }
 
 @inline(never)
 public func run_ReplaceLarge(_ N: Int) {
-    let data = medium
+    let data = sampleData(.medium)
     let replacement = sampleData(.large)
     benchmark_Replace(N, 431..<809, data, replacement)
 }
 
 @inline(never)
 public func run_ReplaceSmallBuffer(_ N: Int) {
-    let data = medium
-    let replacement = small
+    let data = sampleData(.medium)
+    let replacement = sampleData(.small)
     let sz = replacement.count
     replacement.withUnsafeBytes { (ptr: UnsafePointer<UInt8>) in
         benchmark_ReplaceBuffer(N, 431..<809, data, UnsafeBufferPointer(start: ptr, count: sz))

import Foundation

public let DataBenchmarks = [
    BenchmarkInfo(name: "DataSubscript", runFunction: run_Subscript, tags: [.validation, .api, .Data]),
    BenchmarkInfo(name: "DataCount", runFunction: run_Count, tags: [.validation, .api, .Data]),
    BenchmarkInfo(name: "DataSetCount", runFunction: run_SetCount, tags: [.validation, .api, .Data]),
    BenchmarkInfo(name: "DataAccessBytes", runFunction: run_AccessBytes, tags: [.validation, .api, .Data]),
    BenchmarkInfo(name: "DataMutateBytes", runFunction: run_MutateBytes, tags: [.validation, .api, .Data]),
    BenchmarkInfo(name: "DataCopyBytes", runFunction: run_CopyBytes, tags: [.validation, .api, .Data]),
    BenchmarkInfo(name: "DataAppendBytes", runFunction: run_AppendBytes, tags: [.validation, .api, .Data]),
    BenchmarkInfo(name: "DataAppendArray", runFunction: run_AppendArray, tags: [.validation, .api, .Data]),
    BenchmarkInfo(name: "DataReset", runFunction: run_Reset, tags: [.validation, .api, .Data]),
    BenchmarkInfo(name: "DataReplaceSmall", runFunction: run_ReplaceSmall, tags: [.validation, .api, .Data]),

    BenchmarkInfo(name: "DataAppendDataLargeToSmall", runFunction: run_AppendDataLargeToSmall, tags: [.validation, .api, .Data]),
    BenchmarkInfo(name: "DataAppendDataLargeToMedium", runFunction: run_AppendDataLargeToMedium, tags: [.validation, .api, .Data]),
    BenchmarkInfo(name: "DataAppendDataLargeToLarge", runFunction: run_AppendDataLargeToLarge, tags: [.validation, .api, .Data]),
    BenchmarkInfo(name: "DataToStringEmpty", runFunction: run_DataToStringEmpty, tags: [.validation, .api, .Data]),
    BenchmarkInfo(name: "DataToStringSmall", runFunction: run_DataToStringSmall, tags: [.validation, .api, .Data]),
    BenchmarkInfo(name: "DataToStringMedium", runFunction: run_DataToStringMedium, tags: [.validation, .api, .Data]),
    BenchmarkInfo(name: "StringToDataEmpty", runFunction: run_StringToDataEmpty, tags: [.validation, .api, .Data]),
    BenchmarkInfo(name: "StringToDataSmall", runFunction: run_StringToDataSmall, tags: [.validation, .api, .Data]),
    BenchmarkInfo(name: "StringToDataMedium", runFunction: run_StringToDataMedium, tags: [.validation, .api, .Data]),
]

enum SampleKind {
    case small
