android-performance
Advanced tools
Comparing version 1.0.0 to 1.0.1
@@ -203,2 +203,3 @@ 'use strict'; | ||
var token = line.trim().split(/\s+/g); | ||
if (token[0] === 'idx') { | ||
@@ -211,7 +212,7 @@ uidx = _.indexOf(token, 'uid_tag_int'); | ||
if (token[typex].includes('wlan')) { | ||
res.wifi.rcv += token[rcvx]; | ||
res.wifi.snd += token[sndx]; | ||
res.wifi.rcv += parseInt(token[rcvx], 10); | ||
res.wifi.snd += parseInt(token[sndx], 10); | ||
} else { | ||
res.mobile.rcv += token[rcvx]; | ||
res.mobile.rcv += token[sndx]; | ||
res.mobile.rcv += parseInt(token[rcvx], 10); | ||
res.mobile.rcv += parseInt(token[sndx], 10); | ||
} | ||
@@ -218,0 +219,0 @@ } |
{ | ||
"name": "android-performance", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "Node.js wrapper to android performance with adb", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
'use strict'; | ||
var AndroidPerformance = require('..'); | ||
const AndroidPerformance = require('..'); | ||
const pkgName = 'com.android.phone'; | ||
describe('test', function() { | ||
@@ -12,3 +14,3 @@ it('should be ok', function() { | ||
it('should init device success', function(done) { | ||
var perf = new AndroidPerformance(); | ||
const perf = new AndroidPerformance(); | ||
perf.initDevice(function(err, device) { | ||
@@ -24,48 +26,138 @@ if (err) { | ||
it('should get meminfo success', function*() { | ||
var perf = new AndroidPerformance(); | ||
it('should get meminfo success', function *() { | ||
const perf = new AndroidPerformance(); | ||
yield perf.initDevice(); | ||
var res = yield perf.getMeminfoByPackageName('com.android.settings'); | ||
const res = yield perf.getMeminfoByPackageName(pkgName); | ||
console.log(res); | ||
}); | ||
it('should get pid success', function*() { | ||
var perf = new AndroidPerformance(); | ||
it('should get pid success', function *() { | ||
const perf = new AndroidPerformance(); | ||
yield perf.initDevice(); | ||
var res = yield perf.getPid('com.android.settings'); | ||
const res = yield perf.getPid(pkgName); | ||
console.log(res); | ||
}); | ||
it('should get threadcount success', function*() { | ||
var perf = new AndroidPerformance(); | ||
it('should get threadcount success', function *() { | ||
const perf = new AndroidPerformance(); | ||
yield perf.initDevice(); | ||
var pid = yield perf.getPid('com.android.settings'); | ||
var res = yield perf.getThreadCountByPid(pid); | ||
const pid = yield perf.getPid(pkgName); | ||
const res = yield perf.getThreadCountByPid(pid); | ||
console.log(res); | ||
}); | ||
it('should get uid success', function*() { | ||
var perf = new AndroidPerformance(); | ||
it('should get uid success', function *() { | ||
const perf = new AndroidPerformance(); | ||
yield perf.initDevice(); | ||
var pid = yield perf.getPid('com.android.settings'); | ||
var uid = yield perf.getUidByPid(pid); | ||
const pid = yield perf.getPid(pkgName); | ||
const uid = yield perf.getUidByPid(pid); | ||
console.log(uid); | ||
}); | ||
it('should get traffic success', function*() { | ||
var perf = new AndroidPerformance(); | ||
it('should get traffic success', function *() { | ||
const perf = new AndroidPerformance(); | ||
yield perf.initDevice(); | ||
var pid = yield perf.getPid('com.android.settings'); | ||
var uid = yield perf.getUidByPid(pid); | ||
var res = yield perf.getTrafficByUid(uid); | ||
const pid = yield perf.getPid(pkgName); | ||
const uid = yield perf.getUidByPid(pid); | ||
const res = yield perf.getTrafficByUid(uid); | ||
console.log(res); | ||
}); | ||
it('should get CPU success', function*() { | ||
var perf = new AndroidPerformance(); | ||
it('should get CPU success', function *() { | ||
const perf = new AndroidPerformance(); | ||
yield perf.initDevice(); | ||
var pid = yield perf.getPid('com.android.settings'); | ||
var res = yield perf.getCPUByPid(pid); | ||
const pid = yield perf.getPid(pkgName); | ||
const res = yield perf.getCPUByPid(pid); | ||
console.log(res); | ||
}); | ||
it('should all in one with promise', function(done) { | ||
const perf = new AndroidPerformance(); | ||
const p1 = new Promise((resolve, reject) => { | ||
perf | ||
.initDevice() | ||
.then(() => perf.getMeminfoByPackageName(pkgName)) | ||
.then(res => { | ||
resolve({ | ||
item: 'Meminfo', | ||
data: res | ||
}); | ||
}); | ||
}); | ||
const p2 = new Promise((resolve, reject) => { | ||
perf | ||
.initDevice() | ||
.then(() => perf.getPid(pkgName)) | ||
.then(pid => { | ||
return perf | ||
.getThreadCountByPid(pid) | ||
.then(d => { | ||
resolve({ | ||
item: 'ThreadCount', | ||
data: d | ||
}); | ||
}) | ||
.catch(e => { | ||
resolve(null); | ||
}); | ||
}) | ||
.catch(e => { | ||
resolve(null); | ||
}); | ||
}); | ||
const p3 = new Promise((resolve, reject) => { | ||
perf | ||
.initDevice() | ||
.then(() => perf.getPid(pkgName)) | ||
.then(pid => { | ||
return perf | ||
.getUidByPid(pid) | ||
.then(uid => { | ||
return perf | ||
.getTrafficByUid(uid) | ||
.then(d => { | ||
resolve({ | ||
item: 'Traffic', | ||
data: d | ||
}); | ||
}) | ||
.catch(e => { | ||
resolve(null); | ||
}); | ||
}) | ||
.catch(e => { | ||
resolve(null); | ||
}); | ||
}) | ||
.catch(e => { | ||
resolve(null); | ||
}); | ||
}); | ||
const p4 = new Promise((resolve, reject) => { | ||
perf | ||
.initDevice() | ||
.then(() => perf.getPid(pkgName)) | ||
.then(pid => { | ||
return perf | ||
.getCPUByPid(pid) | ||
.then(d => { | ||
resolve({ | ||
item: 'cpu', | ||
data: d | ||
}); | ||
}) | ||
.catch(e => { | ||
resolve(null); | ||
}); | ||
}); | ||
}); | ||
Promise.all([p1, p2, p3, p4]).then(result => { | ||
console.log(`performance:${JSON.stringify(result)}`); | ||
done(); | ||
}); | ||
}); | ||
}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
14050
394
0