Re: [swift-users] Performance critical code in Swift

2016-10-03 Thread Игорь Никитин via swift-users
Thanks for advices! I’m switches to C and will write data to file instead of sqlite It will give me 5x-10x performance growth for writing But it will also increase the time for reading, I think (I've not measured it) I’m also looked for some sqlite alternative, but didn’t found Realm is fast for r

Re: [swift-users] Performance critical code in Swift

2016-10-03 Thread Tino Heth via swift-users
My general advice for performance critical code (especially when it's about stuff like serialization and parsing): If you just want a working solution without spending much time, stick with C. Swift can be fast, but it's harder to write slow code in C. If, on the other hand, coding time is no big

Re: [swift-users] Performance critical code in Swift

2016-10-02 Thread David Hart via swift-users
That fact that Realm has an ORM layer, and that batch inserts are noticeably slower than in SQLite makes it less performant in certain scenarios. The fact that is does not support JOIN queries also causes issues in other performance scenarios. > On 2 Oct 2016, at 20:26, Marco S Hyman via swift-

Re: [swift-users] Performance critical code in Swift

2016-10-02 Thread Marco S Hyman via swift-users
> > On a broader note, I have yet to see a true modern replacement for SQLite on > the embedded side. There are any number of lightweight document stores, but > they either have performance worse than SQLite, or are not really suitable > for embedded use. Realm ??? It’s faster than sqlite and

Re: [swift-users] Performance critical code in Swift

2016-10-02 Thread Maury Markowitz via swift-users
> On Oct 1, 2016, at 4:50 PM, Игорь Никитин via swift-users > wrote: > > For such of tasks C (or maybe C++) is a good choice. But how can Swift do > this as fast as C? > Of course I need to use low level C I/O api, but there are another things > that I need to know? All things considered, the

Re: [swift-users] Performance critical code in Swift

2016-10-01 Thread Игорь Никитин via swift-users
It's isn't just about storing, but also parsing (I parse big json with yajl, the C json parser) and processing that data. And right, name and location is strings > 2 окт. 2016 г., в 0:24, Jens Persson написал(а): > > There's no reason why writing data to disk should be slower in Swift than in

Re: [swift-users] Performance critical code in Swift

2016-10-01 Thread Jens Persson via swift-users
There's no reason why writing data to disk should be slower in Swift than in C/C++. (For the name and location properties, I assume you want to save Strings, a sequence of characters or something rather than just the value of the UnsafePointer.) On Sat, Oct 1, 2016 at 11:22 PM, Игорь Никитин wro

Re: [swift-users] Performance critical code in Swift

2016-10-01 Thread Игорь Никитин via swift-users
I got it. Thanks for your tips! > 2 окт. 2016 г., в 0:13, Jens Persson написал(а): > > You could write some examples in both C and Swift in order to gain experience > in how to write your Swift code so that it will (probably) run as fast as (or > faster than) your corresponding C code. > > I'

Re: [swift-users] Performance critical code in Swift

2016-10-01 Thread Jens Persson via swift-users
You could write some examples in both C and Swift in order to gain experience in how to write your Swift code so that it will (probably) run as fast as (or faster than) your corresponding C code. I've done this for a number of different performance critical things and it is often possible to get t

Re: [swift-users] Performance critical code in Swift

2016-10-01 Thread Игорь Никитин via swift-users
I need to write a specialized data storage (database) for some types that are never changes. This struct can be used as an example: struct User { let id: Int32 let name: UnsafePointer let type: Int32 let location: UnsafePointer } SQLite is super slow. I make few millions inserts

Re: [swift-users] Performance critical code in Swift

2016-10-01 Thread Daniel Dunbar via swift-users
Yes, it is possible. Exactly how much use of Unsafe style idioms and other performance-focused "workarounds" it requires depends a lot on the code in question. Can you say more about your problem area? - Daniel > On Oct 1, 2016, at 1:30 PM, Игорь Никитин via swift-users > wrote: > > Hello!

[swift-users] Performance critical code in Swift

2016-10-01 Thread Игорь Никитин via swift-users
Hello! Is it possible for Swift to be as fast as C when writing performance critical code? Of course if using C Standard Library for instead of Foundation (and so on) and getting rid of dynamic dispatch and reference types. Or I need just to use C? ___