Brooke  Giles

Brooke Giles

1603356240

Performance of removeAll() in a HashSet

Explore the performance of removeAll() in HashSet.

1. Overview

HashSet is a collection for storing unique elements.

In this tutorial, we’ll discuss the performance of the removeAll() method in the _java.util.HashSet _class.

2. HashSet.removeAll()

The removeAll method removes all the elements, that are contained in the collection:

Set<Integer> set = new HashSet<Integer>();
    set.add(1);
    set.add(2);
    set.add(3);
    set.add(4);

    Collection<Integer> collection = new ArrayList<Integer>();
    collection.add(1);
    collection.add(3);

    set.removeAll(collection);

    Integer[] actualElements = new Integer[set.size()];
    Integer[] expectedElements = new Integer[] { 2, 4 };
    assertArrayEquals(expectedElements, set.toArray(actualElements));

As a result, elements 1 and 3 will be removed from the set.

3. Internal Implementation and Time Complexity

The removeAll() method determines which one is smaller – the set or the collection. This is done by invoking the _size() _method on the set and the collection.

If the collection has fewer elements than the set, then it iterates over the specified collection with the time complexity O(n). It also checks if the element is present in the set with the time complexity O(1). And if the element is present, it’s being removed from the set using the remove() method of the set, which again has a time complexity of O(1). So the overall time complexity is O(n).

If the set has fewer elements than the collection, then it iterates over this set using O(n). Then it checks if each element is present in the collection by invoking its contains() method. And if such an element is present, then the element is removed from the set. So this depends on the time complexity of the contains() method.

Now in this case, if the collection is an ArrayList, the time complexity of the contains() method is O(m). So overall time complexity to remove all elements present in the ArrayList from the set is O(n * m).

If the collection is again HashSet, the time complexity of the contains() method is O(1). So overall time complexity to remove all elements present in the HashSet from the set is O(n).

#java #programming #developer

What is GEEK

Buddha Community

Performance of removeAll() in a HashSet
Carmen  Grimes

Carmen Grimes

1595505720

How to Test Mobile App Performance: 3 Key Components - DZone Performance

You’ve probably interacted with an app on your phone or tablet that’s slow, takes a long time to load, freezes, or even crashes on you altogether.

Frustrating, right?

On the flip side, you can probably think of an app that you love to use because from day one, it’s never given you any trouble.

Or maybe you never paid any mind to an app that works quickly, because isn’t that how it’s supposed to be?

So, what causes one app to be crash-prone and another, fast, and reliable?

Whether an app has good or bad performance depends on three factors: the backend, the network, and the app itself running on the device.

A developer or mobile tester can measure the performance of an application in different scenarios.

For example, they can test for when there’s a concurrency of users on the app at the same time, on different devices (which vary in hardware resources and screen sizes), and multiple networks such as 3G, 4G, Wifi, and more.

The reality is that many variables affect the performance of a mobile application. Moreover, a user may have a very bad experience with your app and the cause might not even have anything to do with the code or its implementation.

But, by running performance tests for each of these three factors, you’ll be able to identify problems and optimize your app for the best user experience possible.

Keep reading as we’ll cover the different types of tests for each factor, what to measure, and what tools are available to help you along the way.

1st Mobile Performance Factor: The Backend

A mobile app’s backend architecture is generally based on an application server, a web server, and a database.

**When it comes to the backend, the things related to performance that are important to know when an app is under load are the server’s response times, database queries times, and the server’s resource usage. **

Using this information, it’s easier to detect issues such as:

  • High server response times
  • Bottlenecks or breakpoints in the database and application server resources
  • Poor implementation of escalation policies

So what kind of tests are normally run to check the app’s backend performance? Load tests.

This is when you simulate load on the backend in different ways, whether it be through stress testing, peak testing, endurance testing, load testing, etc.

In general, the objective of these tests is to understand how the backend systems of an app behave and handle a certain volume of concurrent users.

Several tools allow you to load test your mobile app. The most commonly used ones include:

Apache JMeter – the number one open-source load testing tool

Gatling– a developer-friendly, open-source load testing tool with scripts written in Scala

BlazeMeter – a cloud performance testing platform that scales your JMeter or Gatling tests for a greater amount of concurrent users

2nd Mobile Performance Factor: The Network

With regards to the network that the device is connected to, there are two key things to measure: latency and bandwidth.

  • Latency is the time that elapses when information is sent on the network (measured in milliseconds).
  • Bandwidth is the maximum capacity (the amount of data) that can be transmitted through the network (measured in bits per second).

For mobile performance, the lower the latency and the higher the bandwidth, the better.

An app’s performance can vary depending on, for example, whether it’s connected to a 3G network or a 4G network, and unfortunately, this is beyond an app developer or tester’s control.

But, it is possible to incorporate the network during the mobile app performance testing process, simulating the different types of networks and measuring their impact on the response times, both on the server-side and the client-side.

#tutorial #performance #mobile apps #load testing #mobile testing #mobile app performance #client side performance

Joe  Hoppe

Joe Hoppe

1595905879

Best MySQL DigitalOcean Performance – ScaleGrid vs. DigitalOcean Managed Databases

HTML to Markdown

MySQL is the all-time number one open source database in the world, and a staple in RDBMS space. DigitalOcean is quickly building its reputation as the developers cloud by providing an affordable, flexible and easy to use cloud platform for developers to work with. MySQL on DigitalOcean is a natural fit, but what’s the best way to deploy your cloud database? In this post, we are going to compare the top two providers, DigitalOcean Managed Databases for MySQL vs. ScaleGrid MySQL hosting on DigitalOcean.

At a glance – TLDR
ScaleGrid Blog - At a glance overview - 1st pointCompare Throughput
ScaleGrid averages almost 40% higher throughput over DigitalOcean for MySQL, with up to 46% higher throughput in write-intensive workloads. Read now

ScaleGrid Blog - At a glance overview - 2nd pointCompare Latency
On average, ScaleGrid achieves almost 30% lower latency over DigitalOcean for the same deployment configurations. Read now

ScaleGrid Blog - At a glance overview - 3rd pointCompare Pricing
ScaleGrid provides 30% more storage on average vs. DigitalOcean for MySQL at the same affordable price. Read now

MySQL DigitalOcean Performance Benchmark
In this benchmark, we compare equivalent plan sizes between ScaleGrid MySQL on DigitalOcean and DigitalOcean Managed Databases for MySQL. We are going to use a common, popular plan size using the below configurations for this performance benchmark:

Comparison Overview
ScaleGridDigitalOceanInstance TypeMedium: 4 vCPUsMedium: 4 vCPUsMySQL Version8.0.208.0.20RAM8GB8GBSSD140GB115GBDeployment TypeStandaloneStandaloneRegionSF03SF03SupportIncludedBusiness-level support included with account sizes over $500/monthMonthly Price$120$120

As you can see above, ScaleGrid and DigitalOcean offer the same plan configurations across this plan size, apart from SSD where ScaleGrid provides over 20% more storage for the same price.

To ensure the most accurate results in our performance tests, we run the benchmark four times for each comparison to find the average performance across throughput and latency over read-intensive workloads, balanced workloads, and write-intensive workloads.

Throughput
In this benchmark, we measure MySQL throughput in terms of queries per second (QPS) to measure our query efficiency. To quickly summarize the results, we display read-intensive, write-intensive and balanced workload averages below for 150 threads for ScaleGrid vs. DigitalOcean MySQL:

ScaleGrid MySQL vs DigitalOcean Managed Databases - Throughput Performance Graph

For the common 150 thread comparison, ScaleGrid averages almost 40% higher throughput over DigitalOcean for MySQL, with up to 46% higher throughput in write-intensive workloads.

#cloud #database #developer #digital ocean #mysql #performance #scalegrid #95th percentile latency #balanced workloads #developers cloud #digitalocean droplet #digitalocean managed databases #digitalocean performance #digitalocean pricing #higher throughput #latency benchmark #lower latency #mysql benchmark setup #mysql client threads #mysql configuration #mysql digitalocean #mysql latency #mysql on digitalocean #mysql throughput #performance benchmark #queries per second #read-intensive #scalegrid mysql #scalegrid vs. digitalocean #throughput benchmark #write-intensive

Ida  Nader

Ida Nader

1595506545

A Developer's Guide to Optimizing Mobile App Performance - DZone Performance

The invention of mobile phones led to wireless connections between people communicating over a long distance. Users were happy to stay connected with wide coverage offered to them via different cellular phone networks.

Gradually, it became a normal thing for anyone to have a portable phone in their pockets.

As time passed, different innovations influenced the mobile phone technology, thereby, making many functions easier and hassle-free for users.

Today, mobile phones are updated with the latest applications that make various processes and activities easier for daily life. In fact, one cannot imagine life without a mobile phone.

Mobile-app-performance

Why Mobile App Optimization Is Essential

Mobile phones were once a device that enabled communication over a long distance, but now, it has become a tool that makes everything accessible anytime anywhere in just a few clicks.

Starting from booking a cab to ordering food from your favorite restaurant, mobile apps have made life much easier and more convenient than ever before.

As these apps play a dominating role in the lives of individuals, it is important that the performance of these mobile applications is never negatively impacted. This is what makes optimizing mobile app performance a necessity.

Imagine you are too hungry to wait at a restaurant and you pick up your mobile phone to order your favorite food from your favorite restaurant. But, the app is not working properly.

As a result, you are unable to place your order. Will you go back to the same app ever again after the issue? No, right? So, when asked why it is important to optimize a mobile app, the most important answer is user retention.

To be more precise, a mobile app used for any service becomes an important platform for communication between the user and the service provider via easy navigation and proper interface. You can only hold on to a relationship when you can communicate properly.

Hence, having a better communicative platform will definitely lead to improved user retention.

What Factors Affect Mobile App Optimization?

As soon as a developer decides to work on optimizing a mobile app, there are multiple factors that need need their attention:

1. User Expectations

When you are developing a mobile app, think about the customers you or your client are going to serve.

Hence, the process must consider customers or users as the prime factor influencing the development procedure.

While using a mobile app, people want to have an easy user interface along with a stable speed to help the app run. Keep in mind the same concepts when initially developing mobile apps, as well.

2. Adaptive Nature

Mobile applications are used by people irrespective of the places they are in or the time they are contacting their service providers. In short, they may use it from home or on the go.

However, cellular network coverage is not always the same. Hence, being a developer, you must ensure that your app can adapt to changing network coverage offered by different network carriers.

3. User Loss

Remember, if users are not happy while using your app, they won’t come back. Keep this factor in mind and then develop one. If your client loses users, neither they will get the customer back nor will you get your client back. So, be prepared.

When the mobile apps that you develop are in line with the users’ expectations, the latter proves relevant and results in solid feedback and positive reviews online.

#mobile #usability #performance #monitoring #mobile app #optimization #ui #users #app performance

Aileen  Jacobs

Aileen Jacobs

1599205920

ARM64 Performance in .NET 5

The .NET team has significantly improved performance with .NET 5, both generally and for ARM64. You can check out the general improvements in the excellent and detailed Performance Improvements in .NET 5 blog by Stephen. In this post, I will describe the performance improvements we made specifically for ARM64 and show the positive impact on the benchmarks we use. I will also share some of the additional opportunities for performance improvements that we have identified and plan to address in a future release.

While we have been working on ARM64 support in RyuJIT for over five years, most of the work that was done was to ensure that we generate functionally correct ARM64 code. We spent very little time in evaluating the performance of the code RyuJIT produced for ARM64. As part of .NET 5, our focus was to perform investigation in this area and find out any obvious issues in RyuJIT that would improve the ARM64 code quality (CQ). Since Microsoft VC++ team already has support for Windows ARM64, we consulted with them to understand the CQ issues that they encountered when doing a similar exercise.

#.net core #.net internals #c# #dot.net #performance #.net #arm #arm64 #performance #ryujit

Carmen  Grimes

Carmen Grimes

1603945740

Performance Optimization Techniques

Performance is an integral part of the Application design and plays a vital role in the success of your product/application. This is Part-2 of the performance optimization articles series. Performance optimization considerations for an enterprise-level application are discussed as part of Part-1.

Before delving into performance optimization techniques, let us discuss the factors that impact the performance of an application. Below are the most critical factors that impact the performance from my view.

Factors That Impact the Performance of the Application

  • Stuffing home/start page with lots of functionality
  • Making a huge number of API calls/ Loading large JS bundles as part of the initial load of the applications
  • Ineffective JavaScript modules loading strategies (Not effectively using lazy loading)
  • Using large size images without any image optimization/compression
  • Preloading all the data in the browser instead of considering user preferences/user actions
  • Not adopting CDN to deliver the content to the global audience (at least static content/files)
  • Invalid network/tool configurations
  • Using the same website/ APIs for Mobile and Desktop
  • Introducing additional tools only in the production environment

Performance Optimization Techniques

This section gives you an overview of the various techniques that can be employed at various levels of your application. At a global level, below are few areas

User Interface

Below are a few of the core best practices to consider as part of the user interface design and development

User Interface Design Best Practices

  • Consider server-side rendering for your home/landing page if it stuffed with too much functionality
  • Load data on demand always
  • Enabling paging when dealing with large datasets

#javascript #performance #css #best practices #performance optimization