4

On my machine, your original Haskell version run on two copies of the "sa3_10000" test file takes about 20 seconds, while your Go version takes about 2 seconds. Note that profiled GHC binaries run significantly slower, even if you don't generate a profile, so you'll want to make sure you're timing an unprofiled binary when making these comparisons....


3

Welcome to Code Review. There's a lot of points that I may describe here, then I'll do it short. Architecture The wrong point here is sequence of instatiation settings for API helper class and the class itself. Originally instance created first, and only then the proberties are filled. It makes difficult to properly setup HttpClient. I suggest to split ...


2

Rust 1.53.0 (2021-06-17) introduces the IntoIterator for array types, which finally makes this shorter code possible: Algorithm E (flat-map simpler): let output: Vec<u8> = input.iter().flat_map(|val| val.to_be_bytes()).collect(); (This is based on my algorithm D, removing .to_vec(). I did check that algorithm E fails to compile using Rust 1.52.0.) ...


2

In accordance with the D.R.Y. principle: the markup can be simplified by registering a component - and a template can be used with an X-Template. For example - add a <script> tag like this: <script type="text/x-template" id="text-container-template"> <div class="container"> <div class="text-area&...


2

Readability first Indent the code properly. Put every statement in its own line. Name identifiers properly (well, this is mostly done). Separate the algorithm from input/output operations I/O operations are slow. Sometimes it's ok to mix them, but if you want to benchmark your algorithm - move all I/O out of it. The best way would be to create separate ...


1

In order to improve the performance, you can reduce the complexity of the code. Currently, the complexity of your approaches is O(n² log(n)) as the sort function is O(n log(n)) and in each iteration, you are using filter or reduce which has a complexity of O(n). I can suggest one approach where you don't need to sort the elements and so the complexity of the ...


1

Your Java 8 example is less efficient because it iterates over the string's code points twice (once for the countUpperCase method and a second time for countLowerCase). In your first example, you can optimize the code by adding an else clause to the two if statements. Because, if a character is uppercase, you know that if cannot be lowercase, so there's no ...


1

Adding final version, as suggested by @haruo Below code snippet was originally authored by user Noughtmare in response https://www.reddit.com/r/haskell/comments/odfpoe/looking_for_ways_to_improve_performance_of/?utm_source=share&utm_medium=web2x&context=3 at haskell's reddit group with minor tweaking at my end: https://www.reddit.com/r/haskell/...


Only top voted, non community-wiki answers of a minimum length are eligible