Hey gang, First time poster!
I figured the best way to explore the interesting parts of Clojure (for me: STM, Java interop) would be to implement a simple locking problem in Java and Clojure, and pit them against eachother. The results are about what I expected, but I'm sure you all can tell me how I might make Clojure more competitive. http://github.com/stuhood/clojure-conc/tree/master The benchmark contains 4 bi-directional dictionary implementations: * MDict - Java implementation using the synchronized keyword, * RWDict - Java implementation using a ReadWriteLock, * CLJDict - Clojure implementation using the (locking x) macro on Java HashMaps, * STMDict - Clojure implementation using two refs on maps. Run `ant test` to execute the tests. The tests run once with the number of threads set to Runtime.getRuntime().availableProcessors(), and then again with THREAD_MULTIPLIER times that value. The ratio of reads/write can be tuned with READ_MULTIPLE, and the total number of operations is OPERATIONS. The 3 tunables are set in http://github.com/stuhood/clojure-conc/blob/master/src/java/test/com/mailtrust/dict/BaseTestDict.java I can't figure out how to get Clojure to generate a class that accepts generics parameters, so there are some warnings while compiling the tests. Ideas? >>>> On a quad core machine: > [junit] Running com.mailtrust.dict.TestCLJDict > [junit] Tests run: 3, Failures: 0, Errors: 0, Time elapsed: 24.938 sec > [junit] Running com.mailtrust.dict.TestMDict > [junit] Tests run: 3, Failures: 0, Errors: 0, Time elapsed: 2.269 sec > [junit] Running com.mailtrust.dict.TestRWDict > [junit] Tests run: 3, Failures: 0, Errors: 0, Time elapsed: 2.096 sec > [junit] Running com.mailtrust.dict.TestSTMDict > [junit] Tests run: 3, Failures: 0, Errors: 0, Time elapsed: 12.996 sec On a single core machine: > [junit] Running com.mailtrust.dict.TestCLJDict > [junit] Tests run: 3, Failures: 0, Errors: 0, Time elapsed: 12.54 sec > [junit] Running com.mailtrust.dict.TestMDict > [junit] Tests run: 3, Failures: 0, Errors: 0, Time elapsed: 0.422 sec > [junit] Running com.mailtrust.dict.TestRWDict > [junit] Tests run: 3, Failures: 0, Errors: 0, Time elapsed: 0.486 sec > [junit] Running com.mailtrust.dict.TestSTMDict > [junit] Tests run: 3, Failures: 0, Errors: 0, Time elapsed: 5.882 sec Thanks! Stu --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~----------~----~----~----~------~----~------~--~---