Caching and batching generated input strings for testing fa's with same parameters
Opened this issue · 0 comments
Example with generate
option
const { FiniteAutomataTest} = require('fauton');
const finiteAutomataTest = new FiniteAutomataTest(path.join(__dirname, 'logs'));
finiteAutomataTest.test([
{
automaton: startsWithBC,
options: {
type: 'generate',
range: {
maxLength: 10,
},
},
},
{
automaton: doesntStartWithBC,
options: {
type: 'generate',
range: {
maxLength: 12,
},
},
},
{
automaton: startsWith01,
options: {
type: 'generate',
range: {
maxLength: 10,
},
},
},
]);
For testing the first automaton, we generate all the combinations of the alphabet, from a length of 1 to 10, in the 2nd test we use another automaton having the same alphabets to generate the same combinations albeit with 2 increased lengths. This is wasted computation as we could've easily used the inputs of the first automaton and only generate a few more for the 2nd one. Caching the previous result would greatly help in this regard. But if the alphabets are different it should generate them again rather than using cached results from previous computations
Example with file
option
const { FiniteAutomataTest} = require('fauton');
const finiteAutomataTest = new FiniteAutomataTest(path.join(__dirname, 'logs'));
finiteAutomataTest.test([
{
automaton: startsWithBC,
options: {
type: 'generate',
filePath: __dirname + '/input1.txt',
},
},
{
automaton: doesntStartWithBC,
options: {
type: 'file',
filePath: __dirname + '/input1.txt',
},
},
{
automaton: startsWith01,
options: {
type: 'file',
filePath: __dirname + '/input2.txt',
},
},
]);
the same issue as above only difference is that we are creating file streams for each of the input files even if they are the same file. Batching would greatly help improve performance in this regard.
Note that for random
we should not batch or cache anything as it's completely randomly generated.