<commit_before>var assert = require('assert');
var Optical = {};
Optical.OPTIMISED = 1;
Optical.NOT_OPTIMISED = 2;
Optical.ALWAYS_OPTIMISED = 3;
Optical.NEVER_OPTIMSISED = 4;
Optical.MAY_BE_OPTIMISED = 6;

function testOptimisationStatus(fn, args, thisArg) {
	var n =  10000000;
	while (n >= 0) {
		n--;
		fn.apply(thisArg, args);
	}

	%OptimizeFunctionOnNextCall(fn);
	fn.apply(thisArg, args);

	return %GetOptimizationStatus(fn);
}

function printOptimisationStatus(functionName, status) {
    switch(status) {
		case Optical.OPTIMISED: console.log("Function ", functionName, " is optimized"); break;
        case Optical.NOT_OPTIMISED: console.log("Function ", functionName, " is not optimized"); break;
        case Optical.ALWAYS_OPTIMISED: console.log("Function  ", functionName, " is always optimized"); break;
        case Optical.NEVER_OPTIMISED: console.log("Function  ", functionName, " is never optimized"); break;

        case Optical.MAY_BE_OPTIMISED: console.log("Function  ", functionName, " will probably deoptimize"); break;
    }
}


module.exports = function(func, args, thisArg) {
	printOptimisationStatus(func, testOptimisationStatus(func, args, thisArg));
};

module.exports.assertOptimized = function(func, args, thisArg) {
	var optimisationStatus = testOptimisationStatus(func, args, thisArg);
	assert(optimisationStatus === Optical.OPTIMISED || optimisationStatus === Optical.ALWAYS_OPTIMISED);
};
<commit_msg>Indent<commit_after>var assert = require('assert');
var Optical = {};
Optical.OPTIMISED = 1;
Optical.NOT_OPTIMISED = 2;
Optical.ALWAYS_OPTIMISED = 3;
Optical.NEVER_OPTIMSISED = 4;
Optical.MAY_BE_OPTIMISED = 6;

function testOptimisationStatus(fn, args, thisArg) {
	var n =  10000000;
	while (n >= 0) {
		n--;
		fn.apply(thisArg, args);
	}

	%OptimizeFunctionOnNextCall(fn);
	fn.apply(thisArg, args);

	return %GetOptimizationStatus(fn);
}

function printOptimisationStatus(functionName, status) {
    switch(status) {
	case Optical.OPTIMISED: console.log("Function ", functionName, " is optimized"); break;
        case Optical.NOT_OPTIMISED: console.log("Function ", functionName, " is not optimized"); break;
        case Optical.ALWAYS_OPTIMISED: console.log("Function  ", functionName, " is always optimized"); break;
        case Optical.NEVER_OPTIMISED: console.log("Function  ", functionName, " is never optimized"); break;

        case Optical.MAY_BE_OPTIMISED: console.log("Function  ", functionName, " will probably deoptimize"); break;
    }
}


module.exports = function(func, args, thisArg) {
	printOptimisationStatus(func, testOptimisationStatus(func, args, thisArg));
};

module.exports.assertOptimized = function(func, args, thisArg) {
	var optimisationStatus = testOptimisationStatus(func, args, thisArg);
	assert(optimisationStatus === Optical.OPTIMISED || optimisationStatus === Optical.ALWAYS_OPTIMISED);
};

{'fraction_non_alphanumeric': 0.12770411723656663, 'fraction_numerical': 0.009769713886950453, 'mean_word_length': 5.342920353982301, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 2, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '992521', 'n_tokens_mistral': 1003, 'n_tokens_neox': 933, 'n_words': 194}