is regex slower

Benchmark created on


Setup

const regex1 = [/^Invalid request data \(lockTimeOverride\.(SCHEME|CAMPAIGN) must be 1 second or greater\)$/,/^Rule Violation: The maximum number of points sendable as a gift \(\d+\) within the permitted time period \(\d+ hours\) will be exceeded\.$/]

const obj = {
	"Unauthenticated - Check the AUTH headers and the hash is formed correctly":5,
	"Wallet not found.": 5,
	"Identity not found.": 5,
	"Not found (identity not found)": 5,
	"Campaign Unknown": 5,
	"The voucher has expired": 5,
	"Not found": 5,
	"Not found: Resource cannot be found.": 5,
	"Not found: Wallet transaction not found.": 5,
	"Invalid request data (Not enough points available)": 5,
	"Invalid request data (Value does not match a valid redemption rate)":
		5,
	"Campaign Not Found": 5,
	"Invalid request data (wallet transaction already exists with reference)":
		5,
	"Invalid request data: Reference must be unique against the Unit": 5,
	"Insufficient funds": 5,
	// In spendCalculate (and maybe others)
	"Invalid request data (Scheme redemption rates are not configured)": 5,
	// In spendCalculate (and maybe others)
	"Invalid request data (Wallet Transaction already exists)": 5,
	// In spendCalculate  (and maybe others)
	"Invalid request data (No account for this scheme on wallet or household)":
		5,

	// In spendVoid (and maybe others)
	"Not found (Wallet Transaction not found)": 5,

	// In spendVoid
	"Invalid request data (Only active transactions can be voided)": 5,

	// baseEarn
	"Invalid request data (rateName does not exist)": 5,

	// wallet open lock points. Depends of EagleEye scheme configuration
	"Invalid request data (lockTimeOverride.SCHEME must be 1 second or greater)":
		5,
	"Invalid request data (lockTimeOverride.CAMPAIGN must be 1 second or greater)":
		5,

	// wallet open
	"Permissions Engine Error (wallet status: TERMINATED)": 5,

	// wallet open lock points for terminated wallet
	"Unable to remove previous walletTransaction": 5,
};

Test runner

Ready to run.

Testing in
TestOps/sec
regex case
regex1.find((x) => x.test("Rule Violation: The maximum number of points sendable as a gift (123) within the permitted time period (55 hours) will be exceeded"))
ready
obj
obj["Invalid request data (lockTimeOverride.SCHEME must be 1 second or greater)"]
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.