From edbc41dc54a4d301b09e94469c5c1eecb2b8d225 Mon Sep 17 00:00:00 2001 From: Ben Cohen Date: Fri, 28 Oct 2016 09:47:50 -0700 Subject: [PATCH] expanding append(contentsOf:) benchmarks --- benchmark/single-source/ArrayAppend.swift | 97 +++++++++++++++++++++-- benchmark/utils/main.swift | 7 +- 2 files changed, 97 insertions(+), 7 deletions(-) diff --git a/benchmark/single-source/ArrayAppend.swift b/benchmark/single-source/ArrayAppend.swift index ead10b2da63bf..78cee2d5d1207 100644 --- a/benchmark/single-source/ArrayAppend.swift +++ b/benchmark/single-source/ArrayAppend.swift @@ -42,15 +42,14 @@ public func run_ArrayAppendReserved(_ N: Int) { } // Append a sequence. Length of sequence unknown so -// can't pre-reserve capacity. Should be comparable -// to append single elements. +// can't pre-reserve capacity. @inline(never) public func run_ArrayAppendSequence(_ N: Int) { let seq = stride(from: 0, to: 10_000, by: 1) for _ in 0.. { + var x: T + var y: U +} + +// Append another array. Length of sequence known so +// can pre-reserve capacity. +@inline(never) +public func run_ArrayAppendGenericStructs(_ N: Int) { + let other = Array(repeating: S(x: 3, y: 4.2), count: 10_000) + for _ in 0..]() + for _ in 0..<8 { + nums += other + } + } + } +} + +// Append another array. Length of sequence known so +// can pre-reserve capacity. +@inline(never) +public func run_ArrayAppendOptionals(_ N: Int) { + let other: [Int?] = Array(repeating: 1, count: 10_000) + + for _ in 0..