Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
convertRecordsToCsv
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Safari/537.36
Browser:
Chrome 138
Operating system:
Mac OS X 10.15.7
Device Platform:
Desktop
Date tested:
9 months ago
Test name
Executions per second
buildCsvEntry
519.8 Ops/sec
buildCsvEntry Optimized
882.0 Ops/sec
HTML Preparation code:
<!--your preparation HTML code goes here--> <script src='https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.21/lodash.min.js'></script>
Script Preparation code:
const _record = JSON.parse('{"actionTaken":null,"ruleId":"K2OhwBr8uXgoCLSV7qfYIt","sessionId":8367,"segmentLogicalId":"c4aa605c-b959-4ba3-8834-5627c379252a","inputInterface":"VCF","protocol":1,"sourceIp":"233.39.61.186","sourcePort":18120,"destIp":"228.35.238.47","destPort":51975,"destination":"https://yNw34UIPhSBZ7ilxDmsb21.com","domainName":"yNw34UIPhSBZ7ilxDmsb21.com","firewallPolicyName":"CLOSE_7036","segmentName":"Global","application":"Firefox","sessionDurationSecs":921,"bytesSent":4128,"bytesReceived":20606,"closeReason":"","enterpriseLogicalId":"4b534ae2-8f67-4ec8-85a9-768cd4354fcb","edgeLogicalId":"f1db426c-8278-4252-b30a-2d905cfb4918","timestamp":"2025-07-15 04:28:58","engineTypes":[3,4],"urlCategories":[38],"urlCatFilterAction":"DENY","urlRisk":"MEDIUM","urlReputationAction":"DENY"}'); const _schemaFields = JSON.parse('["actionTaken","ruleId","sessionId","segmentLogicalId","inputInterface","protocol","sourceIp","destIp","sourcePort","destPort","destination","domainName","firewallPolicyName","segmentName","extensionHeader","application","sessionDurationSecs","bytesSent","bytesReceived","closeReason","signatureId","signatureName","signatureCategory","signatureSeverity","threatImpact","threatSourceIp","threatSourceGeoCountry","threatTargetIp","enterpriseLogicalId","edgeLogicalId","edgeName","timestamp","idpsAlertType","idpsAction","urlCategories","urlCatFilterAction","urlRisk","urlReputationAction","maliciousIpCategories","malIpAction","engineType"]'); const _schemaFieldMetadata = JSON.parse(`{"actionTaken":{"name":"actionTaken","type":"Enum8('DENY' = 0, 'ALLOW' = 1, 'OPEN' = 2, 'CLOSE' = 3, 'UPDATE' = 4)","default_type":"","default_expression":"","comment":"","codec_expression":"","ttl_expression":"","enums":{"DENY":0,"ALLOW":1,"OPEN":2,"CLOSE":3,"UPDATE":4}},"ruleId":{"name":"ruleId","type":"String","default_type":"","default_expression":"","comment":"","codec_expression":"","ttl_expression":""},"sessionId":{"name":"sessionId","type":"UInt32","default_type":"","default_expression":"","comment":"","codec_expression":"","ttl_expression":""},"segmentLogicalId":{"name":"segmentLogicalId","type":"UUID","default_type":"","default_expression":"","comment":"","codec_expression":"","ttl_expression":""},"inputInterface":{"name":"inputInterface","type":"String","default_type":"","default_expression":"","comment":"","codec_expression":"","ttl_expression":""},"protocol":{"name":"protocol","type":"UInt16","default_type":"","default_expression":"","comment":"","codec_expression":"","ttl_expression":""},"sourceIp":{"name":"sourceIp","type":"String","default_type":"","default_expression":"","comment":"","codec_expression":"","ttl_expression":""},"destIp":{"name":"destIp","type":"String","default_type":"","default_expression":"","comment":"","codec_expression":"","ttl_expression":""},"sourcePort":{"name":"sourcePort","type":"UInt16","default_type":"","default_expression":"","comment":"","codec_expression":"","ttl_expression":""},"destPort":{"name":"destPort","type":"UInt16","default_type":"","default_expression":"","comment":"","codec_expression":"","ttl_expression":""},"destination":{"name":"destination","type":"String","default_type":"","default_expression":"","comment":"","codec_expression":"","ttl_expression":""},"domainName":{"name":"domainName","type":"String","default_type":"","default_expression":"","comment":"","codec_expression":"","ttl_expression":""},"firewallPolicyName":{"name":"firewallPolicyName","type":"String","default_type":"","default_expression":"","comment":"","codec_expression":"","ttl_expression":""},"segmentName":{"name":"segmentName","type":"String","default_type":"","default_expression":"","comment":"","codec_expression":"","ttl_expression":""},"extensionHeader":{"name":"extensionHeader","type":"String","default_type":"","default_expression":"","comment":"","codec_expression":"","ttl_expression":""},"application":{"name":"application","type":"String","default_type":"","default_expression":"","comment":"","codec_expression":"","ttl_expression":""},"sessionDurationSecs":{"name":"sessionDurationSecs","type":"UInt32","default_type":"","default_expression":"","comment":"","codec_expression":"","ttl_expression":""},"bytesSent":{"name":"bytesSent","type":"UInt32","default_type":"","default_expression":"","comment":"","codec_expression":"","ttl_expression":""},"bytesReceived":{"name":"bytesReceived","type":"UInt32","default_type":"","default_expression":"","comment":"","codec_expression":"","ttl_expression":""},"closeReason":{"name":"closeReason","type":"String","default_type":"","default_expression":"","comment":"","codec_expression":"","ttl_expression":""},"signatureId":{"name":"signatureId","type":"UInt32","default_type":"","default_expression":"","comment":"","codec_expression":"","ttl_expression":""},"signatureName":{"name":"signatureName","type":"String","default_type":"","default_expression":"","comment":"","codec_expression":"","ttl_expression":""},"signatureCategory":{"name":"signatureCategory","type":"String","default_type":"","default_expression":"","comment":"","codec_expression":"","ttl_expression":""},"signatureSeverity":{"name":"signatureSeverity","type":"UInt32","default_type":"","default_expression":"","comment":"","codec_expression":"","ttl_expression":""},"threatImpact":{"name":"threatImpact","type":"Enum8('SUSPICIOUS' = 0, 'LOW' = 1, 'MEDIUM' = 2, 'HIGH' = 3, 'CRITICAL' = 4)","default_type":"","default_expression":"","comment":"","codec_expression":"","ttl_expression":"","enums":{"SUSPICIOUS":0,"LOW":1,"MEDIUM":2,"HIGH":3,"CRITICAL":4}},"threatSourceIp":{"name":"threatSourceIp","type":"String","default_type":"","default_expression":"","comment":"","codec_expression":"","ttl_expression":""},"threatSourceGeoCountry":{"name":"threatSourceGeoCountry","type":"String","default_type":"","default_expression":"","comment":"","codec_expression":"","ttl_expression":""},"threatTargetIp":{"name":"threatTargetIp","type":"String","default_type":"","default_expression":"","comment":"","codec_expression":"","ttl_expression":""},"enterpriseLogicalId":{"name":"enterpriseLogicalId","type":"UUID","default_type":"","default_expression":"","comment":"","codec_expression":"","ttl_expression":""},"edgeLogicalId":{"name":"edgeLogicalId","type":"UUID","default_type":"","default_expression":"","comment":"","codec_expression":"","ttl_expression":""},"edgeName":{"name":"edgeName","type":"String","default_type":"","default_expression":"","comment":"","codec_expression":"","ttl_expression":""},"timestamp":{"name":"timestamp","type":"DateTime","default_type":"DEFAULT","default_expression":"now()","comment":"","codec_expression":"","ttl_expression":""},"idpsAlertType":{"name":"idpsAlertType","type":"Enum8('IDS' = 0, 'IPS' = 1)","default_type":"","default_expression":"","comment":"","codec_expression":"","ttl_expression":"","enums":{"IDS":0,"IPS":1}},"idpsAction":{"name":"idpsAction","type":"Enum8('ALLOW' = 0, 'MONITOR' = 1, 'DENY' = 2)","default_type":"","default_expression":"","comment":"","codec_expression":"","ttl_expression":"","enums":{"ALLOW":0,"MONITOR":1,"DENY":2}},"urlCategories":{"name":"urlCategories","type":"Array(UInt16)","default_type":"","default_expression":"","comment":"","codec_expression":"","ttl_expression":""},"urlCatFilterAction":{"name":"urlCatFilterAction","type":"Enum8('ALLOW' = 0, 'MONITOR' = 1, 'DENY' = 2)","default_type":"","default_expression":"","comment":"","codec_expression":"","ttl_expression":"","enums":{"ALLOW":0,"MONITOR":1,"DENY":2}},"urlRisk":{"name":"urlRisk","type":"Enum8('UNKNOWN' = 0, 'HIGH' = 1, 'SUSPICIOUS' = 2, 'MEDIUM' = 3, 'LOW' = 4, 'TRUSTWORTHY' = 5)","default_type":"","default_expression":"","comment":"","codec_expression":"","ttl_expression":"","enums":{"UNKNOWN":0,"HIGH":1,"SUSPICIOUS":2,"MEDIUM":3,"LOW":4,"TRUSTWORTHY":5}},"urlReputationAction":{"name":"urlReputationAction","type":"Enum8('ALLOW' = 0, 'MONITOR' = 1, 'DENY' = 2)","default_type":"","default_expression":"","comment":"","codec_expression":"","ttl_expression":"","enums":{"ALLOW":0,"MONITOR":1,"DENY":2}},"maliciousIpCategories":{"name":"maliciousIpCategories","type":"Array(UInt16)","default_type":"","default_expression":"","comment":"","codec_expression":"","ttl_expression":""},"malIpAction":{"name":"malIpAction","type":"Enum8('ALLOW' = 0, 'MONITOR' = 1, 'DENY' = 2)","default_type":"","default_expression":"","comment":"","codec_expression":"","ttl_expression":"","enums":{"ALLOW":0,"MONITOR":1,"DENY":2}},"engineType":{"name":"engineType","type":"Array(UInt32)","default_type":"","default_expression":"","comment":"","codec_expression":"","ttl_expression":""}}`); const records = []; for (let i = 0; i < 1000; i++) { records.push(_record); } function getSchemaFields(statsType) { return _schemaFields; } function getSchemaFieldMetadata(statsType) { return _schemaFieldMetadata; } function hasValue(value) { if ( (value === null) || (value === undefined) ) return false; return true; } const quoteReplaceRegex = /"/g; function quoteField(val) { if (!_.isNil(val) && _.isString(val)) { return `"${val.replace(quoteReplaceRegex, '""')}"`; } else { return val; } } function quoteFieldEx(val) { if (typeof val === "string") { return `"${val.replaceAll('"', '""')}"`; } else { return val; } } function serializeCategories (categories) { if (_.isArray(categories)) { return `"${categories}"`; } else { return categories; } } function convertMACAddressToInt(macAddress) { macAddress = (!_.isNil(macAddress) && _.isString(macAddress)) ? macAddress.toLowerCase() : '00:00:00:00:00:00'; let pos = 0; let value = 0; let octet = ''; let sep = ':'; let HEX_RE = /^[a-f0-9]$/; let chr, tmp; function isxdigit(c) { return HEX_RE.test(c); } function process() { if (octet.length === 0) { throw new TypeError(`expected to find a hexadecimal number before ${sep}`); } else if (octet.length > 2) { throw new TypeError(`too many hexadecimal digits in ${octet}`); } else if (pos < 6) { tmp = parseInt(octet,16); value *= 0x100; value += tmp; pos += 1; octet = ''; } else { throw new TypeError('too many octets in MAC address'); } } for (let i = 0; i < macAddress.length; i++) { chr = macAddress[i]; if (chr === sep) { process(); } else if (isxdigit(chr)) { octet += chr; } else { throw new TypeError(`unrecognized character ${chr}`); } } if (chr === sep) { throw new TypeError(`trailing ${sep} in MAC address`); } if (pos === 0) { if (octet.length !== 12) { throw new TypeError('MAC address is too short'); } value = parseInt(octet, 16); } else { process(); if (pos !== 6) { throw new TypeError('too few octets in MAC address'); } } return value; } const conversionMap = new Map(); conversionMap.set("sourceMac", convertMACAddressToInt); conversionMap.set("urlCategories", serializeCategories); conversionMap.set("ipCategories", serializeCategories);
Tests:
buildCsvEntry
function buildCsvEntry(record, statsType) { // Build entry for csv and do any additional operations on specific fields. // Double quotes are added around string values. const header = [...getSchemaFields(statsType)]; const columns = []; for (const csvField of header) { let val = _.get(record, csvField); if (hasValue(val)) { if (conversionMap.has(csvField)) { val = conversionMap.get(csvField)(val); } if (['String'].includes(getSchemaFieldMetadata(statsType)[csvField].type)) { val = quoteField(val); } columns.push(`${val}`); } else { columns.push(''); } } // Add trailing comma at end of csv line when joining columns.push(''); header.push(''); return { columns, header }; } for (let i = 0; i < records.length; i++) { buildCsvEntry(records[i], "statsType"); }
buildCsvEntry Optimized
function buildCsvEntryEx(record, statsType) { // Build entry for csv and do any additional operations on specific fields. // Double quotes are added around string values. const header = [...getSchemaFields(statsType)]; const columns = []; for (const csvField of header) { let val = record[csvField]; if (hasValue(val)) { if (conversionMap.has(csvField)) { val = conversionMap.get(csvField)(val); } if ('String' == getSchemaFieldMetadata(statsType)[csvField].type) { val = quoteFieldEx(val); } columns.push(`${val}`); } else { columns.push(''); } } // Add trailing comma at end of csv line when joining columns.push(''); header.push(''); return { columns, header }; } for (let i = 0; i < records.length; i++) { buildCsvEntryEx(records[i], "statsType"); }