<div dir="ltr">I ran with -Ounchecked as most benchmark do, are there more optimization level I&#39;m not aware?</div><div class="gmail_extra"><br><div class="gmail_quote">On Sun, Apr 9, 2017 at 12:44 AM, Shawn Erickson <span dir="ltr">&lt;<a href="mailto:shawnce@gmail.com" target="_blank">shawnce@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div>What optimization level did you try this at? You are also including the print func in your performance test which is a non-trivial amount of code being executed. Also when in doubt profile the code to see the time spent to better nail down the hotspot locations.</div><div><br></div><div>If performance issues exist then leveraging things like a lookup table of pre-built structure can help, etc.</div><div><br></div><div>-Shawn</div><div><br><div class="gmail_quote"><div><div class="h5"><div>On Sat, Apr 8, 2017 at 9:19 AM Proyb P via swift-users &lt;<a href="mailto:swift-users@swift.org" target="_blank">swift-users@swift.org</a>&gt; wrote:<br></div></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5"><div class="m_-6271339662952980068gmail_msg"><div class="m_-6271339662952980068gmail_msg">I have found this took about 0.001s to print 256 characters</div><div class="m_-6271339662952980068gmail_msg">Compare to Python took 0.000016s to print 256 characters, see F8 code and have modify to run only one call instead of 1000 iterations.</div><div class="m_-6271339662952980068gmail_msg"><a href="https://gist.github.com/anonymous/18e372e8d0173e77b5c405920d4d3080" class="m_-6271339662952980068gmail_msg" target="_blank">https://gist.github.com/<wbr>anonymous/<wbr>18e372e8d0173e77b5c405920d4d30<wbr>80</a><br class="m_-6271339662952980068gmail_msg"></div><div class="m_-6271339662952980068gmail_msg"><br class="m_-6271339662952980068gmail_msg"></div>As this is frequently use for server-side swift that will definitely affected by expensive call, are there any alternative solution for converting Int to character close to Python timing?<div class="m_-6271339662952980068gmail_msg"><br class="m_-6271339662952980068gmail_msg"><div class="m_-6271339662952980068gmail_msg"><div class="m_-6271339662952980068gmail_msg"><font face="monospace, monospace" class="m_-6271339662952980068gmail_msg">import Foundation</font></div><div class="m_-6271339662952980068gmail_msg"><font face="monospace, monospace" class="m_-6271339662952980068gmail_msg">var display: String = &quot;&quot;</font></div><div class="m_-6271339662952980068gmail_msg"><font face="monospace, monospace" class="m_-6271339662952980068gmail_msg"><br class="m_-6271339662952980068gmail_msg"></font></div><div class="m_-6271339662952980068gmail_msg"><font face="monospace, monospace" class="m_-6271339662952980068gmail_msg">    func printTimeElapsedWhenRunningCod<wbr>e(title: String, operation: ()-&gt;()) {</font></div><div class="m_-6271339662952980068gmail_msg"><font face="monospace, monospace" class="m_-6271339662952980068gmail_msg">        let startTime = CFAbsoluteTimeGetCurrent()</font></div><div class="m_-6271339662952980068gmail_msg"><font face="monospace, monospace" class="m_-6271339662952980068gmail_msg">        operation()</font></div><div class="m_-6271339662952980068gmail_msg"><font face="monospace, monospace" class="m_-6271339662952980068gmail_msg">        let timeElapsed = CFAbsoluteTimeGetCurrent() - startTime</font></div><div class="m_-6271339662952980068gmail_msg"><font face="monospace, monospace" class="m_-6271339662952980068gmail_msg">        print(&quot;Time elapsed for \(title): \(timeElapsed) s&quot;)</font></div><div class="m_-6271339662952980068gmail_msg"><font face="monospace, monospace" class="m_-6271339662952980068gmail_msg">    }</font></div><div class="m_-6271339662952980068gmail_msg"><font face="monospace, monospace" class="m_-6271339662952980068gmail_msg"><br class="m_-6271339662952980068gmail_msg"></font></div><div class="m_-6271339662952980068gmail_msg"><font face="monospace, monospace" class="m_-6271339662952980068gmail_msg">    printTimeElapsedWhenRunningCod<wbr>e(title: &quot;s1()&quot;) {</font></div><div class="m_-6271339662952980068gmail_msg"><font face="monospace, monospace" class="m_-6271339662952980068gmail_msg">let startingValue = Int((&quot;A&quot; as UnicodeScalar).value) // 65</font></div><div class="m_-6271339662952980068gmail_msg"><font face="monospace, monospace" class="m_-6271339662952980068gmail_msg">for i in 0 ..&lt; 256 {</font></div><div class="m_-6271339662952980068gmail_msg"><font face="monospace, monospace" class="m_-6271339662952980068gmail_msg">    print(Character(UnicodeScalar(<wbr>i + startingValue)!))</font></div><div class="m_-6271339662952980068gmail_msg"><font face="monospace, monospace" class="m_-6271339662952980068gmail_msg">}</font></div><div class="m_-6271339662952980068gmail_msg"><font face="monospace, monospace" class="m_-6271339662952980068gmail_msg">}</font></div></div></div></div></div></div>
______________________________<wbr>_________________<br class="m_-6271339662952980068gmail_msg">
swift-users mailing list<br class="m_-6271339662952980068gmail_msg">
<a href="mailto:swift-users@swift.org" class="m_-6271339662952980068gmail_msg" target="_blank">swift-users@swift.org</a><br class="m_-6271339662952980068gmail_msg">
<a href="https://lists.swift.org/mailman/listinfo/swift-users" rel="noreferrer" class="m_-6271339662952980068gmail_msg" target="_blank">https://lists.swift.org/<wbr>mailman/listinfo/swift-users</a><br class="m_-6271339662952980068gmail_msg">
</blockquote></div></div>
</blockquote></div><br></div>