Skip to content

Instantly share code, notes, and snippets.

@hiragram
Last active April 13, 2017 02:42
Show Gist options
  • Select an option

  • Save hiragram/bfebf334e72fd2dc1f7f334bd690bc34 to your computer and use it in GitHub Desktop.

Select an option

Save hiragram/bfebf334e72fd2dc1f7f334bd690bc34 to your computer and use it in GitHub Desktop.
let count = 100_000_000
let dropCount = count - 1
let array = Array(1...count)
// print(array.dropFirst(dropCount).first) // A
print(array[dropCount]) // B
@hiragram
Copy link
Author

A
./dropFirst 16.81s user 0.29s system 99% cpu 17.131 total
./dropFirst 16.70s user 0.27s system 99% cpu 17.004 total
./dropFirst 16.66s user 0.27s system 99% cpu 16.949 total

B
./dropFirst 16.85s user 0.27s system 99% cpu 17.128 total
./dropFirst 16.78s user 0.27s system 99% cpu 17.064 total
./dropFirst 17.09s user 0.29s system 99% cpu 17.402 total

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment