gintool / gin

GI in No Time - a Simple Microframework for Genetic Improvement
MIT License
43 stars 20 forks source link

Improved ClassLoader documentation and changed how modified classes are stored #38

Closed GiovaniGuizzo closed 4 years ago

GiovaniGuizzo commented 4 years ago

My modifications can be broken down into three:

  1. I changed some documentation of CachedClassLoader. Basically I replaced // with /* */ so that it is properly indexed as Javadoc. I also added more info on parameters and return types;
  2. I changed the way modified classes are stored in the ClassLoader. Before it was using a CompiledClass object, but now it uses a byte[] object. The reasoning behind this modification is to decouple ClassLoader from CompiledClass. If we obtain the bytecode of a class by other means other than compiling it with the respective API, then we can easily integrate the code. Furthermore, it improves the cohesion of CachedClassLoader, because now it does not need to obtain the bytecode, just load it;
  3. I changed some test cases in order to close input and output streams before excluding files. It was causing tests to fail on Windows, because Windows won't allow files to be excluded while they are being read/written by an open stream.

I have also auto-formatted the code of the classes I modified, thus the diff contains some white/trailing space removal, indentation fixes, and unused imports removal.

GiovaniGuizzo commented 4 years ago

I added two new commits (c9b57eb and e1dcfd6).

The first commit fixes a bug in which a line break in Windows would not be recognised (it uses \r\n) during the Trace parsing.

The second commit is a performance improvement. At each writing of files using the samplers, the CSV output stream was being opened and closed. This happened for each new line and it was causing this:

VisualVM

The stream writing and closing was taking as much time as the test execution. With my modification, the output stream is kept open until the end of the "sampleMethods()" execution, preventing constant open, flush, and close of files.

EDIT:

This is the result after the last commit. Both images show the execution of gin in joda-time with ~4.2k test cases.

VisualVM