domingo, 6 de maio de 2018

Measuring and comparing sorting algorithms execution time using JavaFX

JavaFX is a great tool to show data, it has a built in chart API and great tutorials to use it in the internet. I was doing a class on Algorithms and Data Structure because I was concerned about keeping the base concepts fresh in my mind. Using JavaFX I made this small, but still useful, tool to measure execution time of sorting algorithms. See some screenshots:

First you select which algorithm you wanted to run and provide the number of elements to run

The tree will show which algorithm run faster and the slowe

You can visualize each algorithm performance on each amount of elements and compare them
Besidesthe visualization part we also have a few interesting features for basic to intermediary Java programmers:

  • It makes use of threads. I tried to put the algorithms running in different threads;
  • The app uses SPI - Java Service Provider Interface - allowing you to plug any algorithm by just implementing the interface SortAlgorithm (should it be SortingAlgorithm?), packaging it in a JAR and registering your implementation in META-INF/services/org.fxapps.sorting.spi.algorithm.SortAlgorithm, then put the JAR in classpath when running the app.
The code can be found in my github. Certainly it has room for improvements and it has a few bugs - feel free to send me PRs!


Nenhum comentário:

Postar um comentário