Re: [swift-users] Optimal String conversion to/from UTF-8 w/o null-termination?

2017-11-06 Thread Quinn "The Eskimo!" via swift-users
On 6 Nov 2017, at 17:21, Kelvin Ma via swift-users 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

Re: [swift-users] Optimal String conversion to/from UTF-8 w/o null-termination?

2017-11-06 Thread Kelvin Ma via swift-users
doesn’t the compiler like to optimize the loop out of the benchmarking code? i’ve always had a hard time writing benchmarks in Swift On Fri, Nov 3, 2017 at 7:10 PM, Ryan Walklin via swift-users < swift-users@swift.org> wrote: > Why not just profile it? Set up a loop of 100,000 or so with each

Re: [swift-users] Optimal String conversion to/from UTF-8 w/o null-termination?

2017-11-06 Thread Quinn "The Eskimo!" via swift-users
On 3 Nov 2017, at 19:42, Jens Alfke via swift-users wrote: > Any way to pass the bytes directly to String without an intermediate copy? You can do this with `UnsafeBufferPointer`. For example: extension String { init?(bytes: UnsafePointer, count: Int) {

Re: [swift-users] Optimal String conversion to/from UTF-8 w/o null-termination?

2017-11-03 Thread Ryan Walklin via swift-users
Why not just profile it? Set up a loop of 100,000 or so with each method and time it. Ryan > On 4 Nov 2017, at 6:42 am, Jens Alfke via swift-users > wrote: > > I’m working with a C API that represents strings as UTF-8 data tagged with a > length but **without a