jFit (deprecated) (see jfit2)
jFit is a Java utility that automates the generation of Python code for empirical complexity analysis by producing plots of time against input size (n) using Matplotlib, and fitting an appropriate curve
- jFit relies on the Java Runtime Environment (JRE) for its proper execution. To run jFit, a compatible version of JDK and a compatible JVM must be installed on the system. Please refer to the official documentation for specific version requirements
- To execute the generated Python code, install the following packages using pip
pip install scipy numpy matplotlib
- Clone the git repository:
git clone https://github.com/fringewidth/jfit.git
- Open the package in a Java IDE of your choice(e.g., VSCode):
code jfit/jFit
-
Replace the body of
public static void method(long[] array, long n)with the body of the java method of your choice. Thearray[]parameter represents the array to be manipulated, andnsignifies the array's length. -
Important: Limitation on array analysis: Please note that jFit currently supports the analysis of algorithms that work with a single, one dimensional array only.
-
Modify the parameters of
ComplexityAnalyzer.generateMatPlotLib()in themainmethod. Adjust the parameters of:-
startRange: Start of the input sizen -
endRange: End (non-inclusive) of the sizen -
incrementValue: Step size of input sizen -
efficiencyClass: Specify the efficiency class for your method. jFit generates empirical data on the running time across the specifiednrange and fits a corresponding curve.
-
-
The following efficiency classes are currently avaliable:
-
EFFICIENCY_CLASS.CONSTANTfor$O(1)$ complexities -
EFFICIENCY_CLASS.LOGARITHMICfor$O(\log n)$ complexities -
EFFICIENCY_CLASS.LINEARfor$O(n)$ complexities -
EFFICIENCY_CLASS.POLYNOMIALfor$O(n^2)$ complexities -
EFFICIENCY_CLASS.LINEARITHMICfor$O(n\log n)$ complexities -
EFFICIENCY_CLASS.EXPONENTIALfor$O(2^n)$ complexities -
EFFICIENCY_CLASS.FACTORIALfor$O(n!)$ complexities
Support for$O(n^k)$ is planned.
Note: Attempting to analyse linear time curves over large ranges of n results in a plot with several segmented lines, most likely due to caching effects. jFit currently can't fit a good curve to such data, but support for segmented regression is planned.
-
-
Run the script.
- See examples.md for examples and specific use cases.