<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">I need to write a specialized data storage (database) for some types that are never changes. This struct can be used as an example:</div><div class=""><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""><span style="color: rgb(225, 45, 160); font-variant-ligatures: no-common-ligatures;" class=""><br class=""></span></div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""><span style="color: rgb(225, 45, 160); font-variant-ligatures: no-common-ligatures;" class="">struct</span><span style="font-variant-ligatures: no-common-ligatures;" class=""> User {</span></div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""><span style="color: rgb(231, 232, 235); font-variant-ligatures: no-common-ligatures;" class="">&nbsp; &nbsp; </span><span style="color: rgb(225, 45, 160); font-variant-ligatures: no-common-ligatures;" class="">let</span><span style="font-variant-ligatures: no-common-ligatures;" class=""> id: </span><span style="color: rgb(41, 160, 159); font-variant-ligatures: no-common-ligatures;" class="">Int32</span></div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""><span style="color: rgb(231, 232, 235); font-variant-ligatures: no-common-ligatures;" class="">&nbsp; &nbsp; </span><span style="color: rgb(225, 45, 160); font-variant-ligatures: no-common-ligatures;" class="">let</span><span style="color: rgb(231, 232, 235); font-variant-ligatures: no-common-ligatures;" class=""> </span><span style="font-variant-ligatures: no-common-ligatures;" class="">name:</span><span style="color: rgb(231, 232, 235); font-variant-ligatures: no-common-ligatures;" class=""> </span><span style="color: rgb(41, 160, 159); font-variant-ligatures: no-common-ligatures;" class="">UnsafePointer</span><span style="font-variant-ligatures: no-common-ligatures;" class="">&lt;</span><span style="color: rgb(41, 160, 159); font-variant-ligatures: no-common-ligatures;" class="">UInt8</span><span style="font-variant-ligatures: no-common-ligatures;" class="">&gt;</span></div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""><span style="color: rgb(231, 232, 235); font-variant-ligatures: no-common-ligatures;" class="">&nbsp; &nbsp; </span><span style="color: rgb(225, 45, 160); font-variant-ligatures: no-common-ligatures;" class="">let</span><span style="font-variant-ligatures: no-common-ligatures;" class=""> type: </span><span style="color: rgb(41, 160, 159); font-variant-ligatures: no-common-ligatures;" class="">Int32</span></div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""><span style="color: rgb(231, 232, 235); font-variant-ligatures: no-common-ligatures;" class="">&nbsp; &nbsp; </span><span style="color: rgb(225, 45, 160); font-variant-ligatures: no-common-ligatures;" class="">let</span><span style="color: rgb(231, 232, 235); font-variant-ligatures: no-common-ligatures;" class=""> </span><span style="font-variant-ligatures: no-common-ligatures;" class="">location:</span><span style="color: rgb(231, 232, 235); font-variant-ligatures: no-common-ligatures;" class=""> </span><span style="color: rgb(41, 160, 159); font-variant-ligatures: no-common-ligatures;" class="">UnsafePointer</span><span style="font-variant-ligatures: no-common-ligatures;" class="">&lt;</span><span style="color: rgb(41, 160, 159); font-variant-ligatures: no-common-ligatures;" class="">UInt8</span><span style="font-variant-ligatures: no-common-ligatures;" class="">&gt;</span></div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class="">}</span></div></div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""><br class=""></div><div class="">SQLite is super slow. I make few millions inserts and <font face="Menlo" class="">sqlite_step </font>is the problem here (this function takes 15 seconds for all job).&nbsp;</div><div class="">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)</div><div class="">For such of tasks C (or maybe C++) is a good choice. But how can Swift do this as fast as C?</div><div class="">Of course I need to use low level C I/O api, but there are another things that I need to know?</div><br class=""><div><blockquote type="cite" class=""><div class="">1 окт. 2016 г., в 23:33, Daniel Dunbar &lt;<a href="mailto:daniel_dunbar@apple.com" class="">daniel_dunbar@apple.com</a>&gt; написал(а):</div><br class="Apple-interchange-newline"><div class=""><div class="">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?<br class=""><br class=""> - Daniel<br class=""><br class=""><blockquote type="cite" class="">On Oct 1, 2016, at 1:30 PM, Игорь Никитин via swift-users &lt;<a href="mailto:swift-users@swift.org" class="">swift-users@swift.org</a>&gt; wrote:<br class=""><br class="">Hello!<br class="">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.<br class="">Or I need just to use C?<br class="">_______________________________________________<br class="">swift-users mailing list<br class=""><a href="mailto:swift-users@swift.org" class="">swift-users@swift.org</a><br class="">https://lists.swift.org/mailman/listinfo/swift-users<br class=""></blockquote><br class=""></div></div></blockquote></div><br class=""></body></html>