isonic1 / flick

A CLI with helpful QA tools for Android (Devices & Emulators) and iOS (Devices).
MIT License
101 stars 26 forks source link

Feature request: device CPU / memory info #19

Closed sskorol closed 7 years ago

sskorol commented 7 years ago

@isonic1 hi,

Would be great, if flick could retrieve CPU / memory usage info from plugged devices. Some adb examples:

adb -s [udid] shell cat /proc/meminfo
adb -s [udid] shell vmstat
adb -s [udid] shell top -m 10
isonic1 commented 7 years ago

I added this. However, it's based on the app you're testing against. e.g. flick vitals -n com.package.com. This will print out app cpu, app memory and system stats.

sskorol commented 7 years ago

@isonic1 that's great!

But what about global memory / CPU stats? App may crash due to low device resources, and it'd be useful to see the root cause in logs. Does it make sense to you?

P.S. vitals doesn't accept udid at moment. Could you please add this option?

isonic1 commented 7 years ago

It includes both the app memory/cpu usage and total system/global memory/cpu. If app crashes, it will just return to you global system stats. Whoops. let me add the udid.

On Sun, Jan 29, 2017 at 2:46 PM, Sergey Korol notifications@github.com wrote:

@isonic1 https://github.com/isonic1 that's great!

But what about global memory / CPU stats? App may crash due to low resources, and it'd be useful to see the root cause in logs. Does it make sense to you?

P.S. vitals doesn't accept udid at moment. Could you please add this option?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/isonic1/flick/issues/19#issuecomment-275940530, or mute the thread https://github.com/notifications/unsubscribe-auth/ABXXr8WpuC40YjaGvZ0p5bQTXtu5W0Etks5rXOyUgaJpZM4LwvHV .

isonic1 commented 7 years ago

New gem is published. Includes the UDID argument now. Thanks for noticing that.

sskorol commented 7 years ago

@isonic1 just checked, works good, thanks!

As an improvement, would be great to add some user-friendly output, as plenty of : => {} characters is a bit painful for parsing into model. Personally I use flick in a java microservice, and parse cmd output for further sending to remote clients.

isonic1 commented 7 years ago

Oh, it should return JSON. So if you assign the output to variable. e.g. perf = flick vitals -p android -n com.myawesomeapp.com it will give you a hash. Might come back as a string. If so, you should be able to convert it to JSON. After, you should then do something like perf[:app_stats][:memory] or however you get your JSON objects in Java. Does this not work?

isonic1 commented 7 years ago

Not sure if this helps at all. Looks like in Java it's harder to do than other languages. For instance, in Ruby I could just do eval(perf) around the string to turn it back into a hash.

http://stackoverflow.com/questions/26485964/how-to-convert-string-into-hashmap-in-java

sskorol commented 7 years ago

@isonic1 sorry, missed your last comment.

vitals command returns the following:

{:app_stats=>{:memory_mb=>0.0, :cpu_per=>0}, :system_stats=>{:user=>0, :system=>2, :iow=>0, :irq=>0}}

It's not a valid json format, and it can't be converted to json as well (without additional pre-processing).