time() timezone name, l1 cache improvements
This commit is contained in:
+20
-10
@@ -781,7 +781,7 @@ function getCpu() {
|
||||
try {
|
||||
const workload = [];
|
||||
workload.push(util.powerShell('Get-WmiObject Win32_processor | fl *'));
|
||||
workload.push(util.powerShell('Get-WmiObject Win32_CacheMemory | select CacheType,InstalledSize,Purpose | fl *'));
|
||||
workload.push(util.powerShell('Get-WmiObject Win32_CacheMemory | select CacheType,InstalledSize,Level | fl *'));
|
||||
// workload.push(util.powerShell('Get-ComputerInfo -property "HyperV*"'));
|
||||
workload.push(util.powerShell('(Get-CimInstance Win32_ComputerSystem).HypervisorPresent'));
|
||||
|
||||
@@ -852,16 +852,21 @@ function getCpu() {
|
||||
parts.forEach(function (part) {
|
||||
lines = part.split('\r\n');
|
||||
const cacheType = util.getValue(lines, 'CacheType');
|
||||
const purpose = util.getValue(lines, 'Purpose');
|
||||
const level = util.getValue(lines, 'Level');
|
||||
const installedSize = util.getValue(lines, 'InstalledSize');
|
||||
// L1 Instructions
|
||||
if (purpose === 'L1 Cache' && cacheType === '3') {
|
||||
if (level === '3' && cacheType === '3') {
|
||||
result.cache.l1i = parseInt(installedSize, 10);
|
||||
}
|
||||
// L1 Data
|
||||
if (purpose === 'L1 Cache' && cacheType === '4') {
|
||||
if (level === '3' && cacheType === '4') {
|
||||
result.cache.l1d = parseInt(installedSize, 10);
|
||||
}
|
||||
// L1 all
|
||||
if (level === '3' && cacheType === '5' && !result.cache.l1i && !result.cache.l1d) {
|
||||
result.cache.l1i = parseInt(installedSize, 10) / 2;
|
||||
result.cache.l1d = parseInt(installedSize, 10) / 2;
|
||||
}
|
||||
});
|
||||
// lines = data[2].split('\r\n');
|
||||
// result.virtualization = (util.getValue(lines, 'HyperVRequirementVirtualizationFirmwareEnabled').toLowerCase() === 'true');
|
||||
@@ -1413,21 +1418,26 @@ function cpuCache(callback) {
|
||||
if (result.l2) { result.l2 = parseInt(result.l2, 10) * 1024; }
|
||||
if (result.l3) { result.l3 = parseInt(result.l3, 10) * 1024; }
|
||||
}
|
||||
util.powerShell('Get-WmiObject Win32_CacheMemory | select CacheType,InstalledSize,Purpose | fl ').then((stdout, error) => {
|
||||
util.powerShell('Get-WmiObject Win32_CacheMemory | select CacheType,InstalledSize,Level | fl ').then((stdout, error) => {
|
||||
if (!error) {
|
||||
const parts = stdout.split(/\n\s*\n/);
|
||||
parts.forEach(function (part) {
|
||||
const lines = part.split('\r\n');
|
||||
const cacheType = util.getValue(lines, 'CacheType');
|
||||
const purpose = util.getValue(lines, 'Purpose');
|
||||
const level = util.getValue(lines, 'Level');
|
||||
const installedSize = util.getValue(lines, 'InstalledSize');
|
||||
// L1 Instructions
|
||||
if (purpose === 'L1 Cache' && cacheType === '3') {
|
||||
result.l1i = parseInt(installedSize, 10);
|
||||
if (level === '3' && cacheType === '3') {
|
||||
result.cache.l1i = parseInt(installedSize, 10);
|
||||
}
|
||||
// L1 Data
|
||||
if (purpose === 'L1 Cache' && cacheType === '4') {
|
||||
result.l1d = parseInt(installedSize, 10);
|
||||
if (level === '3' && cacheType === '4') {
|
||||
result.cache.l1d = parseInt(installedSize, 10);
|
||||
}
|
||||
// L1 all
|
||||
if (level === '3' && cacheType === '5' && !result.cache.l1i && !result.cache.l1d) {
|
||||
result.cache.l1i = parseInt(installedSize, 10) / 2;
|
||||
result.cache.l1d = parseInt(installedSize, 10) / 2;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
+1
-2
@@ -35,12 +35,11 @@ const _sunos = (_platform === 'sunos');
|
||||
|
||||
function time() {
|
||||
let t = new Date().toString().split(' ');
|
||||
|
||||
return {
|
||||
current: Date.now(),
|
||||
uptime: os.uptime(),
|
||||
timezone: (t.length >= 7) ? t[5] : '',
|
||||
timezoneName: (t.length >= 7) ? t.slice(6).join(' ').replace(/\(/g, '').replace(/\)/g, '') : ''
|
||||
timezoneName: Intl ? Intl.DateTimeFormat().resolvedOptions().timeZone : (t.length >= 7) ? t.slice(6).join(' ').replace(/\(/g, '').replace(/\)/g, '') : ''
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user