Android Debate v0.6 Released

Posted in Android Debate on May 8th, 2012 by Ryan Marcus – Be the first to comment

I (finally) put out a new version of Android Debate today. Functionality wise, it isn’t too much different from the previous version, but it is a lot cleaner, and you can search through judges and view their paradigms!

Changelog:

- Choose timer sounds
- Progress bar!
- Fully configurable times
- Judge paradigms (currently they just open as links, but that will be changed in a future version)
- New look and feel!

I imagine I’ll have a lot more time this summer to work on the app, and I plan on adding a lot more features, including many that integrate with DebateResults.

Check it out on your phones or on Google Play here: https://play.google.com/store/apps/details?id=info.rmarcus.debate.

Lyapunov Fractals in Python: Performance and Pretty Pictures

Posted in Computer Tips, Personal on April 15th, 2011 by Ryan Marcus – Be the first to comment

I spent some time earlier this week playing around with Lyapunov fractals in Python. While normally I wouldn’t consider Python to be a performance-packing language, the ease-of-use (programmer cycles vs. machine cycles) inherent in Python has always been attractive. However, I was able to speed up my Python code substantially using Psyco, the Python multiprocessing module, and a fast implementation of Python called PyPy.

Lyapunov fractals are generated from a specific binary sequence, generally denoted with A’s and B’s. For example, the sequence “ABA” produces a different fractal than the sequence “BBAA.” An algorithm for generating these fractals is described by the Wolfram folk here.

Lyapunov fractals are formed by associating an exponent (which, from what I can determine, is generally between -2.0 and 2.0) with a color. Each point on a 4.0×4.0 plane gets an exponent. A visual representation of the fractal is then formed by associating each exponent with a color.

Because of the computationally intense aspects of calculating an exponent, I decided to create one program to calculate all the exponent data, saving it to a file*, and another program to create an image from it. My source is available at the end of the post.

After I’d written my code, I felt the wraith of Python in the form of slowness. After some trivial optimizations, I found Pysco and the Python multiprocessing module.

Psyco is pretty straightforward: it does a bunch of JIT-style compilation (read: magic) on vanilla python to speed it up. It is pretty easy to use:

import psyco
psyco.full()

Or, if you are slightly more error-cautious:


try:
   import psyco
   psyco.full()
   print "Psyco'd!"
except ImportError:
   print "No psyco"
   pass

The Python multiprocessing library is a real gem. It provides a parallel version of the “map” function. This is pretty awesome — since each exponent calculation depends only upon a point (embarrassingly parallel), it is easy to create a function that takes in a point and spits out an exponent.

Of course, all the concerns of parallel programming still apply. You can’t have any race conditions, and your code needs to be conceptually parallel. Python takes care of all the messy bits (semaphores, join/fork management, etc.) for you.

If you were using the map() function like this:

a = map (function, list)

… you can simply replace that line with:


try:
   from multiprocessing import Pool
   pool = Pool(8)
   print "Parallel!"
   a = pool.map(function, list)
except ImportError:
   print "Not parallel"
   a = map(function, list)

This will preform the map function in parallel (if the multiprocessing module is available) using 8 workers (which is pretty optimal for an i7 920).

I also discovered an alternative flavor of Python called PyPy, which is a performance-driven Python that uses technology similar to Psyco. Sadly, PyPy doesn’t have an implementation of the multiprocessing module, so I was forced to choose between PyPy and traditional Python with multiprocessing and Psyco. I was incredibly doubtful that PyPy’s speed would be able to make up for parallelism and Psyco. I’ll let the numbers talk for me.

The test system contains an un-overclocked i7 920 and 3GB of DDR3 RAM. These numbers are from generating a 1000×1000 fractal worth of data with the sequence “AB” to a depth of 500 (iterations). I run Ubuntu 10.10 32-bit.

Time in seconds. Smaller is better.

Trial Python with Psyco and MP Python with Pysco Python with MP Python PyPy
Trial 1 36.4 273 253 2041 71
Trial 2 36.3 268 258 2042 66
Trial 3 35.2 269 255 2058 71
Average 35.966667 270 255.333333 2047 69.33333333

Clearly, Python on its own is pretty darn slow. Psyco provides nearly a 10x speedup, and if you can write your code to take advantage of the multiprocessing library, you can go really fast.

The PyPy results, compared to the Pysco results, are quite impressive. If PyPy had an implementation of the multiprocessing library (which I’m fairly certain it doesn’t — feel free to correct me), it would probably dominate.

The multiprocessing results for this test aren’t completely fair — generating fractals is an embarrassingly parallel problem. But, of course, if you can break your problem up into parallel pieces, you can expect a relatively big speed bump.

Conclusion: Python doesn’t have to be as slow as Python normally is. Drop-in replacements like Psyco can greatly accelerate code. if your code is vanilla enough to not require many external libraries (like PIL) then PyPy can probably give you quite the boost as well.

You can download my source here.

Here’s some pretty pictures:

* A note about pickle: I realize that many Python developers would’ve decided to use pickle (or the faster cPickle) to save their exponent data to a file. I found cPickle to be far, far slower than just writing out comma separated values.

Evidence Auto Cutter Homepage

Posted in Evidence Auto Cutter on March 26th, 2011 by Ryan Marcus – Be the first to comment

I’ve moved the homepage for the evidence auto cutter to a WordPress page. You can access it from the navigation area on the right, or through the old URL: http://marcusfamily.info/ryan/

Future updates about the evidence cutter will be posted here.

Android Debate v0.5 Released

Posted in Android Debate on August 19th, 2010 by Ryan Marcus – Be the first to comment

Today I released version 0.5 of Android Debate. I added a “profiles” section to allow you to quickly change between high school and college CX timings. By request of Ben Batha.

Android Debate 0.4 Released

Posted in Android Debate on March 28th, 2010 by Ryan Marcus – Be the first to comment

Today I released beta version 0.4 of Android Debate. The new version prevents the screen from going to sleep while the app is open. This was a user request from a user named Tom.

Android Debate Update 0.3

Posted in Android Debate on January 31st, 2010 by Ryan Marcus – Be the first to comment

The newest version of Android Debate (uploaded today) has support for high school and college CX as well as college CX timings. Check and out and leave a comment!

Just search the Market for “debate”

Browser Wars on MacBook Pro 17″ 2.66 4GB

Posted in Computer Tips on January 26th, 2010 by Ryan Marcus – Be the first to comment

My results:

Android Debate Beta Release

Posted in Android Debate on January 21st, 2010 by Ryan Marcus – Be the first to comment

I’m pleased to announce my very first published Android app. Android Debate is a simple policy debate round timer that can currently only be used for high school rounds (the timers stop at 8 minutes and 5 minutes). While currently in a very early beta, I plan to add more features, including:

  • Judge Wiki
  • Customizable times (for use in college rounds)
  • Out round calculator
  • And more! (based on your suggestions!)

You can give Android Debate a try right now for free. Just search for it in the Android market.


openSUSE wireless installation

Posted in Computer Tips on December 27th, 2009 by Ryan Marcus – Be the first to comment

Recently, I’ve been using openSUSE to try to get a grasp on a really powerful Linux distribution. So far, I’m really enjoying the power and simplicity of YaST and Zyppher. However, when I installed openSUSE on my laptop, I was having some trouble figuring out how to get my wireless card to work.

I started at this page on the openSUSE forms: http://forums.opensuse.org/network-internet/wireless/410319-getting-your-wireless-work.html and from there I dove into log files, and then stumbled upon a very interesting website, http://wireless.kernel.org, in which I finally found my way to this page. From there, I was able to find a very useful command built into openSUSE that fetched the proper firmware for most laptop wireless cards. So, if you are trying to get wifi on openSUSE to work, give this command a shot:

sudo /usr/sbin/install_bcm43xx_firmware

Wine vs. Windows Vista

Posted in Computer Tips on March 17th, 2009 by Ryan Marcus – Be the first to comment

After reviewing my previous post regarding benchmarks between Wine and Windows, I decided the conclusions needed updating for multiple reasons:

  1. Wine has evolved quite a bit — we now have a “stable” 1.0 release as well as other new releases.
  2. Windows has been updated since Windows XP — namely, Windows Vista.
  3. Hardware has changed drastically

The machine I am running these benchmarks on (my machine):

  1. Core i7 920
  2. 3x1GB DDR3 1333 RAM
  3. MSI X86 Platinum
  4. XFX GTX 260 Black Edition

Benchmarks were ran on Ubuntu Intrepid and Windows Vista, all with every available (default) updates (including service packs) and no other applications running. I disabled desktop effects in Ubuntu, and I disabled Aero (I set the theme “Windows Classic”) in Vista. I used Cinebench R10 in WINE version 1.1.17.

Results were as follows:

Test Vista Ubuntu Percent
Single CPU Rendering 3190 3197 0.2% for Linux
Multiple CPU Rendering 13039 11060 15.2% for Windows
OpenGL 4873 7634 36.2% for Linux

A few interesting things to note:

  1. WINE and Windows have almost exactly the same performance for running processes that only use one CPU (single thread.)
  2. Windows scales better then WINE scales. WINE will fall behind when running processor-intensive multi-threaded applications, but the application would be far from unusable.
  3. WINE is substantially better then Windows (36.2%) at running OpenGL applications, which means games and other software that use OpenGL may actually run better in WINE then in Windows.