 
 @inline(never)
 public func run_ReplaceLargeBuffer(_ N: Int) {
-    let data = medium
+    let data = sampleData(.medium)
     let replacement = sampleData(.large)
     let sz = replacement.count
     replacement.withUnsafeBytes { (ptr: UnsafePointer<UInt8>) in


func benchmark_AppendData(_ N: Int, _ lhs: Data, _ rhs: Data) {
    var data = lhs
    for _ in 1...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 {
        // 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 {
        // Ensure that the compiler does not optimize away this call
        blackHole(data.count)
    }
}

@inline(never)
public func run_SetCount(_ N: Int) {
    let data = 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
    benchmark_AccessBytes(N, data)
}

@inline(never)
public func run_MutateBytes(_ N: Int) {
    let data = medium
    benchmark_MutateBytes(N, data)
}

@inline(never)
public func run_CopyBytes(_ N: Int) {
    let data = medium
    benchmark_CopyBytes(N, data)
}

@inline(never)
public func run_AppendBytes(_ N: Int) {
    let data = medium
    benchmark_AppendBytes(N, 809, data)
}

@inline(never)
public func run_AppendArray(_ N: Int) {
    let data = medium
    benchmark_AppendArray(N, 809, data)
}

@inline(never)
public func run_Reset(_ N: Int) {
    let data = medium
    benchmark_Reset(N, 431..<809, data)
}

@inline(never)
public func run_ReplaceSmall(_ N: Int) {
    let data = medium
    let replacement = small
    benchmark_Replace(N, 431..<809, data, replacement)
}

@inline(never)
public func run_ReplaceMedium(_ N: Int) {
    let data = medium
    let replacement = medium
    benchmark_Replace(N, 431..<809, data, replacement)
}

@inline(never)
public func run_ReplaceLarge(_ N: Int) {
    let data = 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 sz = replacement.count
    replacement.withUnsafeBytes { (ptr: UnsafePointer<UInt8>) in
        benchmark_ReplaceBuffer(N, 431..<809, data, UnsafeBufferPointer(start: ptr, count: sz))

    case .string: return sampleString()
    case .immutableBacking: return sampleBridgedNSData()
    }
    
}

func benchmark_AccessBytes(_ N: Int, _ data: Data) {
    for _ in 0..<10000*N {
        data.withUnsafeBytes { (ptr: UnsafePointer<UInt8>) in
            // Ensure that the compiler does not optimize away this call
            blackHole(ptr.pointee)
