Java Appium Automation Memory Testing - java

have a set of automation scripts that were written in Java TestNG with Appium running across iOS and Android devices. What I'd like to do is at certain intervals when performing certain actions, check the available memory of the device, or the memory that the application under test is using. The purpose of this would be to find memory leaks and/or other performance issues over a period of time.
I am aware of using the Instruments tool in OSX to track memory, but I'd like to do this checking programmatically such that it can be contained into our CI process and data can be collected over a period of time instead of manually.
Any tips/tricks on how to accomplish this?

Related

Android memory: how to inspect memory without using Profiler?

I have a problem of OOM error (OutOfMemory) with my app. It seems that it is due to an object that takes more and more room in memory but I don't manage to find which one.
I would like to use the Android Profiler to find the problem. But I have a real time app that uses a lot the device processor and memory, and when I use the Profiler the app becomes really slow and becomes almost impossible to use (I need to use the app at least 3 minutes at normal speed in order to see the memory growing progressively).
My questions are:
is there a way to use the Profiler without this slowdown issue?
if not, are there any other tools or methodology in order to help me finding which object grows in memory?
Thanks !
You can collect your app's heapdump using adb shell
adb shell am dumpheap <PID> <TARGET_FILE>
and view the exported file using android studio profiler
Alternatively, if you know when exactly in your app the OOM happens, you can collect the heapdump using this method Debug.dumpHprofData(String)

JxBrowser takes huge RAM

I am using jxbrowser to make an automation test application.
After run a lot of automation tests(login to a webpage, click some button, perform some UI interaction), I reallize that the jxbroser-chromium.exe took so huge RAM, Even after doing some automation tests, I load "about:blank" page
Note that I use only one instance of Browser & BrowserView
Is there any way to clean & clear RAM when using jxbrowser?
JxBrowser is based on Chromium engine. Chromium engine is running in the jxbrowser-chromium.exe process. JxBrowser doesn't control the memory in this process. All memory management is done by Chromium engine. If you see that the process allocates too much memory, then it means that Chromium engine decided to allocate this amount of memory for some reasons.
I believe if you do the same automated tests in Google Chrome tab, you will see the same memory usage issue. As far as I know there's no Chromium API that would clear the memory of an existing tab/browser. To clear the memory I can only suggest that you dispose Browser instance and create it again.

Will parallel execution on selenium grid affect the execution time

I'm writing automated scripts to load thousands of records into the web application and the time frame in which data has to be loaded is very less. So I thought of using Selenium Grid to run the scripts in parallel to achieve lesser time. Now, My question is will this affect the execution time of the automated scripts or the hub machine. There will be around 20 machines or maybe even more connected to the hub.
Also, Is using selenium grid the best option for this or I could use some other approach as well. And, feeding data from database or using web services is not possible.
Thanks in advance.
will this affect the execution time of the automated scripts or the hub machine
Maybe. It depends on the rest of your stack. Is the underlying server multi-threaded; will each Selenium Grid instance be provisioned its own process on the server? What about your database - will transaction locking block the other processes? Will any of your servers hit some performance bottleneck? Is the database ACID compliant? - I.e. Will running multiple Selenium instances like this cause race condition errors?
There's only one way to know for sure: Do a trial run, and benchmark it.
Is using selenium grid the best option for this or I could use some other approach as well
If you have direct access to the database, then you could seed the data directly (using SQL, presumably). This would be much faster, if it's a viable option.
Also, it depends what you're typing to achieve here. Are you simply seeding the application with a tonne of data? (In which case, SQL is a better option.) Or, are you actually performance-testing the website? (In which case, intense parallel execution may be part of the specs.)

Tool to monitor & log system metrics during automated Java performance tests

We have an application using Spring Integration in its core, and have created performance tests to see what is the processing speed (msgs/sec) for different generated input types.
This process is automated, so whenever such test is run, a separate instance is created in cloud, and disposed after done & output artefacts copied.
What I want to do is to have those performance tests monitored during the run for basic system metrics -- CPU, memory, I/O, GC runs/time. Obviously, the result of this should be some CSV files with metrics readings (e.g., once or twice a second).
So my question is: Are there any good and configurable tools for these purposes?
I'm in the middle of investigation, but profiling tools I reviewed so far mainly require human interaction and are UI oriented.
An option I'm considering is writing a separate tool to access MXBean & use it to log such data during the performance tests. Just wondering if anything good is around.
Please note that this application is running in Tomcat, however for the performance tests we are only using Spring Integration's File endpoints.
Please also note, that 'switchable' component within application is also possible solution. However, I'm currently looking for application-agnostic external tools-first solution.
Command-line tools come to help for this kind of a scenario:
On a Linux/Solaris based environment:
Before you run/trigger your JVM for Spring based application, you can run tools like vmstat, sar in a background mode with its output redirected to a flat file - which helps capture CPU, Memory and other such statistics. Use top with options or mpstat to get thread-level statistics if you seem to be hitting a performance problem, to do bottleneck analysis.
Now run the JVM with arguments like printgc, -Xloggc to write JVM verbose output to a flat file or print gc statictics. Look under Debugging options section for JVM arguments in Java HotSpot VM Options for more options you need.
Tip: create a shell script combining both commands above to run at the same time and achieve your requirement.
On a Windows environment:
For OS statistics gathering on commandline, you could use typeperf or tracerpt (CSV supported).
Now run the JVM with arguments like printgc, -Xloggc to write JVM verbose output to a flat file or print gc statictics. Look under Debugging options section for JVM arguments in Java HotSpot VM Options for more options you need.
Jmeter is a tool to develop performance and scalability tests (defining http requests and being able to load the server with them) , but also has a plugin to allow for monitoring a target system for system metrics such as CPU utilization, memory utlization etc and also JMX type statistics:
Available JMX metric types:
gc-time - time spent in garbage collection, milliseconds (used method)
memory-usage - heap memory used by VM, bytes (method used)
memory-committed - heap memory committed by VM, bytes (method used)
memorypool-usage - heap memory pool usage, bytes (method used)
memorypool-committed - heap memory pool committed size, bytes (method used)
class-count - loaded class count in VM (used method)
compile-time - time spent in compilation, milliseconds (used method)"
Check http://jmeter-plugins.org/wiki/PerfMonMetrics/ for more details of this plugin.

How to to reduce startup time and memory consumption of a java program?

I assume the latest update version of java would provide better performance.
I am looking for a way to implement isolation of software components from endless loops or memory leaks. Android isolates each app in it's own process, Google Chrome isolates each tab in it's own process.
My primary drawback is that java takes so long to start and also I would like to reduce memory consumption.
Is there any alternate build or more controlled startup that will accomplish this?
If quick startup is your goal, Java on a PC may not be your best bet. It's going to take a few seconds because that's how long it takes to load the VM from disk.
If you want your app to start more quickly it's easy to get a splash screen up, just create a module that only loads your splash screen, waits for it to fully display then uses reflection to link to your "Real" main module.
(Use reflection because otherwise it will pull in your entire program through references before it starts the main one--at least that's how it used to work).
If you're talking about run-time performance, you won't get quicker by changing languages, Java's about as fast as you can get. You MIGHT be able to get a boost by converting to C/C++ and rewriting it to suit those platforms (Less OO, stack allocations instead of heap, etc), but otherwise none of the other languages in general usage are close to Java in speed.
If you really need the quick startup, depending on what you are doing there may be some tricks. I've seen projects that try to keep a Java VM running in your toolbar and allow you to make requests (tell it to start an app). This was faster but made additional requirements of the user (Loading this additional tool)
Another possibility--if you are constantly starting up/shutting down small tasks and that's the reason the startup bothers you then you can definitely speed it up by keeping it running invisibly. Just have your Java app open a socket and listen for commands then create a little .EXE or shell script that can start your program if it's not running or send commands to that socket if it is. This would completely eliminate startups after the first run.
In general, Java has a much longer startup time than other languages. If you are sticking with Java on a desktop app, a lot of stuff like startup time is determined by the JRE installed on the client's computer, which you can't control.
As to "endless memory leaks"... Java doesn't leak memory. If your program does, fix it.
This is a second answer because it's completely different and my other got too long :)
Try compiling it--I think GCC can compile it. This could almost completely eliminate your startup. I believe Jikes used to be a windows java compiler by IBM, but I don't know if it's still maintained.
Note that compiled code will probably run slower than JVM code for long-running apps.

Categories