How-to articles, tricks, and solutions about PERFORMANCE

C++ performance vs. Java/C#

C++ is generally considered to be a faster and more performant language than Java or C#.

Convert Set to List without creating new List

To convert a Set to a List in Java without creating a new List object, you can use the List constructor that takes a Collection as an argument.

Deleting DataFrame row in Pandas based on column value

In Pandas, you can delete a row in a DataFrame based on a certain column value by using the drop() method and passing the index label of the row you want to delete.

Fastest way to check if a value exists in a list

The fastest way to check if a value exists in a list is to use the in operator.

Get difference between two lists with Unique Entries

You can use the set data type to find the difference between two lists with unique entries.

How can I read a large text file line by line using Java?

To read a large text file line by line in Java, you can use a BufferedReader and pass it a FileReader object to read the file. Here's an example of how you can do this:

How do I measure elapsed time in Python?

There are several ways to measure elapsed time in Python.

How to benchmark efficiency of PHP script

There are several ways to benchmark the efficiency of a PHP script, including:

How to calculate the running time of my program?

To calculate the running time of a program in Java, you can use the System.currentTimeMillis() method to get the current time in milliseconds before and after the program runs.

How to find Java Heap Size and Memory Used (Linux)?

To find the Java heap size and the amount of memory used on a Linux system, you can use the jstat command and specify the process ID (PID) of the Java process.

Most efficient way to map function over numpy array

There are several ways to apply a function to every element of a numpy array, and the most efficient method will depend on the size and shape of the array, as well as the complexity of the function.

StringBuilder vs String concatenation in toString() in Java

In Java, you can use either a StringBuilder or string concatenation to create a string representation of an object.

Why does Python code run faster in a function?

Python code can run faster in a function because of something called "Just-In-Time" (JIT) compilation.

Why is "1000000000000000 in range(1000000000000001)" so fast in Python 3?

The range() function generates a sequence of numbers, starting from the first argument, and ending before the second argument.

Why is processing a sorted array faster than processing an unsorted array in Java?

Processing a sorted array can be faster than processing an unsorted array because certain algorithms and operations have a lower average time complexity when the input is already sorted.