Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Caching and batching generated input strings for testing fa's with same parameters #4

Open
Devorein opened this issue Nov 13, 2021 · 0 comments
Assignees
Labels
enhancement New feature or request

Comments

@Devorein
Copy link
Owner

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.

@Devorein Devorein self-assigned this Nov 13, 2021
@Devorein Devorein added the enhancement New feature or request label Nov 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant