On 6 Nov 2017, at 17:21, Kelvin Ma via swift-users <swift-users@swift.org> 
wrote:

> doesn’t the compiler like to optimize the loop out of the benchmarking code?

Yep.  I would resolve this by reading the input from a file.  For example, in 
the data-to-String case, you could:

1. Read lots of individual chunks of data from the file

2. Run each chunk through the `String` initialiser

3. Count how many chunks work and how many fail, so the output depends on the 
input

4. Print that number, which prevents the compiler optimising the whole thing 
away

Share and Enjoy
--
Quinn "The Eskimo!"                    <http://www.apple.com/developer/>
Apple Developer Relations, Developer Technical Support, Core OS/Hardware


_______________________________________________
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users

Reply via email to