Skip to content
David Hofer edited this page Jul 11, 2015 · 6 revisions

Welcome to the majority-element wiki!

To build and run:

make

To clear out the binaries:

make clean

What does this do?

I wrote programs in different languages that

  • Read in a csv file with a single line,
  • parse the line into an array of strings,
  • iterate over the array and keep a count of the occurrences of each unique element,
  • report if some element occurs more than half of the time

Caveat

This is incredibly unscientific and a very basic test to boot. The goal is for me to get some kind of sense of how fast different languages are, and to try different ones out with a common solution to a simple problem. I wouldn't read too much into this as a benchmark.

That said, recent output

https://travis-ci.org/dahofer/majority-element/builds/70553560

What's the deal with the "small input file" for Haskell and Swift?

I wasn't able to find a way to read from a file in Swift when compiled to an OS X binary (I guess it's possible as an iOS binary). Haskell seems to have trouble parsing the medium-sized file (~7MB). I like Haskell but I don't love it, so I probably won't debug it, but if someone knows what's going on I'd happily accept a fix.

Please

If I am abusing a language, or there's a faster way to do something, let me know.