/**
* Built-in Map keyed by device id, pre-populated with the same 7 devices as
* devices_list / devices_object, so test3 (Map.get) runs on the same data as
* test1 (array scan) and test2 (object lookup). Each entry is [id, device].
*/
const devices_map = new Map([
[
"88b70563-4061-4ae6-ba89-0ba5b13dedfb",
{
"id": "88b70563-4061-4ae6-ba89-0ba5b13dedfb",
"deviceName": "а, е, ё, и, о, у, ы, э, ю, я",
"activated": true,
"deviceType": "MIC xxx",
"serialNo": "D 749 375",
"ip": "192.168.82.35",
"port": 5001,
"slaveEnabled": false,
"slaveIP": "0.0.0.0",
"slavePort": 5001,
"slaveIsMS": false,
"containerID": "214cf924079cb9054debd759c0eda105030d232e8ad9c4a5222ecc11c7a7f9e7",
"manufSN": "1",
"tz": null,
"coreHealth": "Sick"
}
],
[
"fb96def6-4b13-4186-88b3-9fb2f6e7e7d6",
{
"id": "fb96def6-4b13-4186-88b3-9fb2f6e7e7d6",
"deviceName": "MS120",
"activated": true,
"deviceType": "ADBus - TP XX",
"serialNo": "S 212 121",
"ip": "192.168.82.36",
"port": 5001,
"slaveEnabled": false,
"slaveIP": "192.168.82.130",
"slavePort": 5001,
"slaveIsMS": false,
"containerID": "28886c090a7f5f9d6064b16499c72f45306104c7822ca8dac484e697387e3a90",
"manufSN": "03",
"tz": null,
"coreHealth": "Healthy"
}
],
[
"d0b7b748-ad5f-4a5c-ba49-076def0c60ee",
{
"id": "d0b7b748-ad5f-4a5c-ba49-076def0c60ee",
"deviceName": "MS220",
"activated": true,
"deviceType": "TP xxx",
"serialNo": "S 945 210",
"ip": "192.168.82.36",
"port": 5001,
"slaveEnabled": false,
"slaveIP": "0.0.0.0",
"slavePort": 5001,
"slaveIsMS": false,
"containerID": "add9e66e001acb67873a3229162e40e9fe377747372d861f4b5753bff42828f5",
"manufSN": "02",
"tz": null,
"coreHealth": "Healthy"
}
],
[
"3861577d-611d-4df3-b36f-df336f661b53",
{
"id": "3861577d-611d-4df3-b36f-df336f661b53",
"deviceName": "ms3",
"activated": true,
"deviceType": "TP xxx",
"serialNo": "S 618 124",
"ip": "192.168.82.36",
"port": 5001,
"slaveEnabled": false,
"slaveIP": "0.0.0.0",
"slavePort": 5001,
"slaveIsMS": false,
"containerID": "082ba7b1e9ab4940eaa7f81932cce52c0a67658bbdca4b3ea035ad6ea5b27719",
"manufSN": "04",
"tz": null,
"coreHealth": "Sick"
}
],
[
"593fb834-0c62-4114-9355-3636a95a7a82",
{
"id": "593fb834-0c62-4114-9355-3636a95a7a82",
"deviceName": "ms4",
"activated": true,
"deviceType": "TP xxx",
"serialNo": "S 637 103",
"ip": "192.168.82.36",
"port": 5001,
"slaveEnabled": false,
"slaveIP": "0.0.0.0",
"slavePort": 5001,
"slaveIsMS": false,
"containerID": "8ae7e78fb1fbdea611bdb591fecb953d06ec432cb7f7db4025e7e50e4aafbd21",
"manufSN": "05",
"tz": null,
"coreHealth": "Sick"
}
],
[
"0558b5e2-3432-433e-ad5c-3c9d6b5eb09e",
{
"id": "0558b5e2-3432-433e-ad5c-3c9d6b5eb09e",
"deviceName": "ms5",
"activated": true,
"deviceType": "TP xxx",
"serialNo": "S 602 104",
"ip": "192.168.82.36",
"port": 5001,
"slaveEnabled": false,
"slaveIP": "0.0.0.0",
"slavePort": 5001,
"slaveIsMS": false,
"containerID": "66c9d719f98f8f724ce7cbe302b4d8b3bbcd9057baf796742572a469d4a8173c",
"manufSN": "06",
"tz": null,
"coreHealth": "Sick"
}
],
[
"945a09cf-da00-4fa7-9f6a-4f267bb9e1ba",
{
"id": "945a09cf-da00-4fa7-9f6a-4f267bb9e1ba",
"deviceName": "ms6",
"activated": true,
"deviceType": "TP xxx",
"serialNo": "S 512 102",
"ip": "192.168.82.36",
"port": 5001,
"slaveEnabled": false,
"slaveIP": "0.0.0.0",
"slavePort": 5001,
"slaveIsMS": false,
"containerID": "081debb89247029680c21f01945afa5b27f3bceddff7544165163a5869e7550f",
"manufSN": "7",
"tz": "Europe/Berlin",
"coreHealth": "Sick"
}
]
])
const devices_list = [
{
"id": "88b70563-4061-4ae6-ba89-0ba5b13dedfb",
"deviceName": "а, е, ё, и, о, у, ы, э, ю, я",
"activated": true,
"deviceType": "MIC xxx",
"serialNo": "D 749 375",
"ip": "192.168.82.35",
"port": 5001,
"slaveEnabled": false,
"slaveIP": "0.0.0.0",
"slavePort": 5001,
"slaveIsMS": false,
"containerID": "214cf924079cb9054debd759c0eda105030d232e8ad9c4a5222ecc11c7a7f9e7",
"manufSN": "1",
"tz": null,
"coreHealth": "Sick"
},
{
"id": "fb96def6-4b13-4186-88b3-9fb2f6e7e7d6",
"deviceName": "MS120",
"activated": true,
"deviceType": "ADBus - TP XX",
"serialNo": "S 212 121",
"ip": "192.168.82.36",
"port": 5001,
"slaveEnabled": false,
"slaveIP": "192.168.82.130",
"slavePort": 5001,
"slaveIsMS": false,
"containerID": "28886c090a7f5f9d6064b16499c72f45306104c7822ca8dac484e697387e3a90",
"manufSN": "03",
"tz": null,
"coreHealth": "Healthy"
},
{
"id": "d0b7b748-ad5f-4a5c-ba49-076def0c60ee",
"deviceName": "MS220",
"activated": true,
"deviceType": "TP xxx",
"serialNo": "S 945 210",
"ip": "192.168.82.36",
"port": 5001,
"slaveEnabled": false,
"slaveIP": "0.0.0.0",
"slavePort": 5001,
"slaveIsMS": false,
"containerID": "add9e66e001acb67873a3229162e40e9fe377747372d861f4b5753bff42828f5",
"manufSN": "02",
"tz": null,
"coreHealth": "Healthy"
},
{
"id": "3861577d-611d-4df3-b36f-df336f661b53",
"deviceName": "ms3",
"activated": true,
"deviceType": "TP xxx",
"serialNo": "S 618 124",
"ip": "192.168.82.36",
"port": 5001,
"slaveEnabled": false,
"slaveIP": "0.0.0.0",
"slavePort": 5001,
"slaveIsMS": false,
"containerID": "082ba7b1e9ab4940eaa7f81932cce52c0a67658bbdca4b3ea035ad6ea5b27719",
"manufSN": "04",
"tz": null,
"coreHealth": "Sick"
},
{
"id": "593fb834-0c62-4114-9355-3636a95a7a82",
"deviceName": "ms4",
"activated": true,
"deviceType": "TP xxx",
"serialNo": "S 637 103",
"ip": "192.168.82.36",
"port": 5001,
"slaveEnabled": false,
"slaveIP": "0.0.0.0",
"slavePort": 5001,
"slaveIsMS": false,
"containerID": "8ae7e78fb1fbdea611bdb591fecb953d06ec432cb7f7db4025e7e50e4aafbd21",
"manufSN": "05",
"tz": null,
"coreHealth": "Sick"
},
{
"id": "0558b5e2-3432-433e-ad5c-3c9d6b5eb09e",
"deviceName": "ms5",
"activated": true,
"deviceType": "TP xxx",
"serialNo": "S 602 104",
"ip": "192.168.82.36",
"port": 5001,
"slaveEnabled": false,
"slaveIP": "0.0.0.0",
"slavePort": 5001,
"slaveIsMS": false,
"containerID": "66c9d719f98f8f724ce7cbe302b4d8b3bbcd9057baf796742572a469d4a8173c",
"manufSN": "06",
"tz": null,
"coreHealth": "Sick"
},
{
"id": "945a09cf-da00-4fa7-9f6a-4f267bb9e1ba",
"deviceName": "ms6",
"activated": true,
"deviceType": "TP xxx",
"serialNo": "S 512 102",
"ip": "192.168.82.36",
"port": 5001,
"slaveEnabled": false,
"slaveIP": "0.0.0.0",
"slavePort": 5001,
"slaveIsMS": false,
"containerID": "081debb89247029680c21f01945afa5b27f3bceddff7544165163a5869e7550f",
"manufSN": "7",
"tz": "Europe/Berlin",
"coreHealth": "Sick"
}
]
const devices_object = {
"88b70563-4061-4ae6-ba89-0ba5b13dedfb": {
"id": "88b70563-4061-4ae6-ba89-0ba5b13dedfb",
"deviceName": "а, е, ё, и, о, у, ы, э, ю, я",
"activated": true,
"deviceType": "MIC xxx",
"serialNo": "D 749 375",
"ip": "192.168.82.35",
"port": 5001,
"slaveEnabled": false,
"slaveIP": "0.0.0.0",
"slavePort": 5001,
"slaveIsMS": false,
"containerID": "214cf924079cb9054debd759c0eda105030d232e8ad9c4a5222ecc11c7a7f9e7",
"manufSN": "1",
"tz": null,
"coreHealth": "Sick"
},
"fb96def6-4b13-4186-88b3-9fb2f6e7e7d6": {
"id": "fb96def6-4b13-4186-88b3-9fb2f6e7e7d6",
"deviceName": "MS120",
"activated": true,
"deviceType": "ADBus - TP XX",
"serialNo": "S 212 121",
"ip": "192.168.82.36",
"port": 5001,
"slaveEnabled": false,
"slaveIP": "192.168.82.130",
"slavePort": 5001,
"slaveIsMS": false,
"containerID": "28886c090a7f5f9d6064b16499c72f45306104c7822ca8dac484e697387e3a90",
"manufSN": "03",
"tz": null,
"coreHealth": "Healthy"
},
"d0b7b748-ad5f-4a5c-ba49-076def0c60ee": {
"id": "d0b7b748-ad5f-4a5c-ba49-076def0c60ee",
"deviceName": "MS220",
"activated": true,
"deviceType": "TP xxx",
"serialNo": "S 945 210",
"ip": "192.168.82.36",
"port": 5001,
"slaveEnabled": false,
"slaveIP": "0.0.0.0",
"slavePort": 5001,
"slaveIsMS": false,
"containerID": "add9e66e001acb67873a3229162e40e9fe377747372d861f4b5753bff42828f5",
"manufSN": "02",
"tz": null,
"coreHealth": "Healthy"
},
"3861577d-611d-4df3-b36f-df336f661b53": {
"id": "3861577d-611d-4df3-b36f-df336f661b53",
"deviceName": "ms3",
"activated": true,
"deviceType": "TP xxx",
"serialNo": "S 618 124",
"ip": "192.168.82.36",
"port": 5001,
"slaveEnabled": false,
"slaveIP": "0.0.0.0",
"slavePort": 5001,
"slaveIsMS": false,
"containerID": "082ba7b1e9ab4940eaa7f81932cce52c0a67658bbdca4b3ea035ad6ea5b27719",
"manufSN": "04",
"tz": null,
"coreHealth": "Sick"
},
"593fb834-0c62-4114-9355-3636a95a7a82": {
"id": "593fb834-0c62-4114-9355-3636a95a7a82",
"deviceName": "ms4",
"activated": true,
"deviceType": "TP xxx",
"serialNo": "S 637 103",
"ip": "192.168.82.36",
"port": 5001,
"slaveEnabled": false,
"slaveIP": "0.0.0.0",
"slavePort": 5001,
"slaveIsMS": false,
"containerID": "8ae7e78fb1fbdea611bdb591fecb953d06ec432cb7f7db4025e7e50e4aafbd21",
"manufSN": "05",
"tz": null,
"coreHealth": "Sick"
},
"0558b5e2-3432-433e-ad5c-3c9d6b5eb09e": {
"id": "0558b5e2-3432-433e-ad5c-3c9d6b5eb09e",
"deviceName": "ms5",
"activated": true,
"deviceType": "TP xxx",
"serialNo": "S 602 104",
"ip": "192.168.82.36",
"port": 5001,
"slaveEnabled": false,
"slaveIP": "0.0.0.0",
"slavePort": 5001,
"slaveIsMS": false,
"containerID": "66c9d719f98f8f724ce7cbe302b4d8b3bbcd9057baf796742572a469d4a8173c",
"manufSN": "06",
"tz": null,
"coreHealth": "Sick"
},
"945a09cf-da00-4fa7-9f6a-4f267bb9e1ba": {
"id": "945a09cf-da00-4fa7-9f6a-4f267bb9e1ba",
"deviceName": "ms6",
"activated": true,
"deviceType": "TP xxx",
"serialNo": "S 512 102",
"ip": "192.168.82.36",
"port": 5001,
"slaveEnabled": false,
"slaveIP": "0.0.0.0",
"slavePort": 5001,
"slaveIsMS": false,
"containerID": "081debb89247029680c21f01945afa5b27f3bceddff7544165163a5869e7550f",
"manufSN": "7",
"tz": "Europe/Berlin",
"coreHealth": "Sick"
}
}
function getDeviceFromList(id) {
return devices_list.find(a => a.id == id)
}
function getDeviceFromObject(id) {
return devices_object?.[id]
}
/**
* Returns the device with the given id via Map.get (hash lookup), or undefined.
* The third variant, so it can be compared with the array scan and the object lookup.
*/
function getDeviceFromMap(id) {
return devices_map.get(id)
}Initializing...
| Test Case | Ops/sec | |
|---|---|---|
| test | | ready |
| test2 | | ready |
| test3 | | ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.