From fcc82e37ba3f8c1d14d6b310ed05345e02f7adbe Mon Sep 17 00:00:00 2001 From: CN_SZTL Date: Sat, 21 Mar 2020 22:30:02 +0800 Subject: [PATCH] autocore: show cpubench score --- package/lean/autocore/files/rpcd_10_system.js | 15 +++++++++++---- package/lean/autocore/files/rpcd_luci | 10 ++++++++++ package/lean/autocore/files/rpcd_luci-base.json | 2 +- package/lean/coremark/coremark.sh | 4 ++-- 4 files changed, 24 insertions(+), 7 deletions(-) diff --git a/package/lean/autocore/files/rpcd_10_system.js b/package/lean/autocore/files/rpcd_10_system.js index 2c46afdf6f..fc0d42c061 100644 --- a/package/lean/autocore/files/rpcd_10_system.js +++ b/package/lean/autocore/files/rpcd_10_system.js @@ -12,6 +12,11 @@ var callSystemInfo = rpc.declare({ method: 'info' }); +var callCPUBench = rpc.declare({ + object: 'luci', + method: 'getCPUBench' +}); + var callCPUInfo = rpc.declare({ object: 'luci', method: 'getCPUInfo' @@ -29,6 +34,7 @@ return L.Class.extend({ return Promise.all([ L.resolveDefault(callSystemBoard(), {}), L.resolveDefault(callSystemInfo(), {}), + L.resolveDefault(callCPUBench(), {}), L.resolveDefault(callCPUInfo(), {}), L.resolveDefault(callCPUUsage(), {}), fs.lines('/usr/lib/lua/luci/version.lua') @@ -38,9 +44,10 @@ return L.Class.extend({ render: function(data) { var boardinfo = data[0], systeminfo = data[1], - cpuinfo = data[2], - cpuusage = data[3], - luciversion = data[4]; + cpubench = data[2], + cpuinfo = data[3], + cpuusage = data[4], + luciversion = data[5]; luciversion = luciversion.filter(function(l) { return l.match(/^\s*(luciname|luciversion)\s*=/); @@ -65,7 +72,7 @@ return L.Class.extend({ var fields = [ _('Hostname'), boardinfo.hostname, - _('Model'), boardinfo.model, + _('Model'), boardinfo.model + cpubench.cpubench, _('CPU Info'), cpuinfo.cpuinfo, _('Architecture'), boardinfo.system, _('Firmware Version'), (L.isObject(boardinfo.release) ? boardinfo.release.description + ' / ' : '') + (luciversion || ''), diff --git a/package/lean/autocore/files/rpcd_luci b/package/lean/autocore/files/rpcd_luci index ba62f4506a..4a3e54bbc9 100755 --- a/package/lean/autocore/files/rpcd_luci +++ b/package/lean/autocore/files/rpcd_luci @@ -629,6 +629,16 @@ local methods = { end }, + getCPUBench = { + call = function() + local sys = require "luci.sys" + local cpubench = {} + + cpubench.cpubench = sys.exec("cat /etc/bench.log 2>/dev/null") + return cpubench + end + }, + getOnlineUsers = { call = function() local sys = require "luci.sys" diff --git a/package/lean/autocore/files/rpcd_luci-base.json b/package/lean/autocore/files/rpcd_luci-base.json index 2f4a3cb55b..4d9eaa0ab1 100644 --- a/package/lean/autocore/files/rpcd_luci-base.json +++ b/package/lean/autocore/files/rpcd_luci-base.json @@ -61,7 +61,7 @@ "ubus": { "file": [ "list", "read", "stat" ], "iwinfo": [ "assoclist", "freqlist", "txpowerlist", "countrylist" ], - "luci": [ "getConntrackList", "getInitList", "getLocaltime", "getProcessList", "getRealtimeStats", "getTimezones", "getLEDs", "getUSBDevices", "getSwconfigFeatures", "getSwconfigPortState", "getBlockDevices", "getMountPoints", "getCPUUsage", "getOnlineUsers", "getETHInfo" ], + "luci": [ "getConntrackList", "getInitList", "getLocaltime", "getProcessList", "getRealtimeStats", "getTimezones", "getLEDs", "getUSBDevices", "getSwconfigFeatures", "getSwconfigPortState", "getBlockDevices", "getMountPoints", "getCPUBench", "getCPUUsage", "getOnlineUsers", "getETHInfo" ], "luci-rpc": [ "getBoardJSON", "getDHCPLeases", "getDSLStatus", "getDUIDHints", "getHostHints", "getNetworkDevices", "getWirelessDevices" ], "network.interface": [ "dump" ], "network.rrdns": [ "lookup" ], diff --git a/package/lean/coremark/coremark.sh b/package/lean/coremark/coremark.sh index 6b0f9f127a..4f041bbea8 100755 --- a/package/lean/coremark/coremark.sh +++ b/package/lean/coremark/coremark.sh @@ -3,10 +3,10 @@ /bin/coremark > /tmp/coremark.log cat /tmp/coremark.log | grep "CoreMark 1.0" | cut -d "/" -f 1 > /etc/bench.log -sed -i 's/CoreMark 1.0/(CpuMark/g' /etc/bench.log +sed -i 's/CoreMark 1.0/ (CpuMark/g' /etc/bench.log echo " Scores)" >> /etc/bench.log if [ -f "/etc/bench.log" ]; then sed -i '/coremark/d' /etc/crontabs/root crontab /etc/crontabs/root -fi \ No newline at end of file +fi