[swift-users] Performance critical code in Swift

Игорь Никитин devnikor at icloud.com
Sat Oct 1 15:50:07 CDT 2016

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<UInt8>
    let type: Int32
    let location: UnsafePointer<UInt8>

SQLite is super slow. I make few millions inserts and sqlite_step is the problem here (this function takes 15 seconds for all job). 
So I need to save to the disk few million instances of this struct as fast as possible (this is why I need a custom db)
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?

> 1 окт. 2016 г., в 23:33, Daniel Dunbar <daniel_dunbar at apple.com> написал(а):
> 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 <swift-users at swift.org> wrote:
>> 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?
>> _______________________________________________
>> swift-users mailing list
>> swift-users at swift.org
>> https://lists.swift.org/mailman/listinfo/swift-users

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-users/attachments/20161001/445bfbb2/attachment.html>

More information about the swift-users mailing list