Skip to main content
The 2024 Developer Survey results are live! See the results

# Questions tagged [performance]

Performance is a subset of Optimization: performance is the goal when you want the execution time of your program or routine to be optimal.

7,743 questions
Filter by
Sorted by
Tagged with
3 votes
1 answer
92 views

### Efficient polynomial multiplication in Python

I'm practicing problems for the ICPC competition, and one of the problems requires solving it by using an FFT to compute the product of two polynomials efficiently. Since this is for the ICPC ...
• 165
2 votes
0 answers
45 views

### Speed up recursively looping through network folder and subfolders in VBA

I'm trying to loop through around 100k files in varying degrees of nested directories using vba and md5 hashing each of those files. Right now, the current state of the program takes around 1.5 to 2 ...
• 21
0 votes
0 answers
68 views

### Benchmarking Square root functions

Here's a follow-up to my posts about square roots (Studies on Square Roots and More Square Root). I've tidied up the code, but there's still a lot to do according to the feedback of the other posts. ...
• 141
1 vote
2 answers
105 views

### A simple performant factorial function

I am new to algorithm and data structure. After a little introduction to the topic, I have decided to implement a function called calculateFactorial, which takes an integer and calculates its ...
1 vote
1 answer
75 views

### Finding the number of distinct decompositions a number has using only repdigits

This is a problem from a previous semester that I am trying to upsolve. I am trying to solve a problem involving the total number of ways of decomposing a number using only repdigits. A repdigit is a ...
2 votes
1 answer
72 views

### A search function that searches for a contact inside a vector [closed]

I have this function to search for a specific contact inside a contact management program. I want to know the following: Is returning the contact object as a pointer(...
2 votes
1 answer
79 views

### Speed up searching for the lowest element that is not in the array

I try to solve this question: B. Informatics in MAC at Codeforces To solve it, I think I need to calculate the prefix and suffix array of MEX. I made observation that making only 1 subsegment will ...
• 161
5 votes
2 answers
947 views

### Optimized data structure mapping finite set of integers to values in C++

I'm looking for a mapping data structure, but knowing that the possible values of my keys are small numbers, I would like to trade memory for better performances (for both random access and value ...
• 611
8 votes
2 answers
1k views

### Beginner level password generator optimization

I've been learning python for a few days now, and I programmed this password generator after today's lesson (following the 100 days of code on udemy course). This code works like it should and gives ...
• 83
5 votes
3 answers
914 views

### Optimizing Pi Estimation Code

I'm trying to write a program in Python that estimates pi, but to get a more accurate estimation in a feasible amount of time, I want to make it faster. I'm using a method that estimates the area of ...
7 votes
8 answers
1k views

### Reversing vowels in a string

Given a string s, reverse only all the vowels in the string and return it. The vowels are 'a', 'e', 'i', 'o', and 'u', and they can appear in both lower and upper ...
2 votes
2 answers
75 views

### A thread-safe performant Money Transfer API in Java

This is a popular interview question. It is meant to be done within 30 minutes. The task is to implement a thread-safe performant Bank Account API that allows to transfer, deposit, withdraw and check ...
• 343
6 votes
3 answers
974 views

### Implement Huffman code in C17

I just finished my first coding project. Prior to this I have only made small programs so I'd like some feedback on what to improve on and how I did in general. The whole code is 658 lines long. The ...
1 vote
0 answers
51 views

### Bi-Directional A* function in MATLAB

I am currently working on my thesis for 3D path planning involving external elements, and I have completed about 1/5 of the total trials that I am doing. For each 1/5 of the trials I am increasing the ...
• 11
2 votes
1 answer
70 views

### CSV Data Plotting Program using CsvHelper in C#

This is a follow-up question for CSV Data Plotting Program in C#. I am trying to use CsvHelper to build an application for plotting CSV Data in this post. In the ...
• 5,466
4 votes
1 answer
137 views

...
• 97
5 votes
3 answers
860 views

### Project Euler 127 - abc-hits

Problem (Rephrased from here): The radical of $n$, $rad(n)$, is the product of distinct prime factors of $n$. For example, $504 = 2^3 × 3^2 × 7$, so $rad(504) = 2 × 3 × 7 = 42$. We shall ...
1 vote
0 answers
48 views

### Solving upper triangular matrix-vector equation in Rust

Most linear algebra libraries written for Rust, e.g. nalgebra or ndarray have type or trait requirements that mean their ...
• 575
1 vote
0 answers
23 views

### Bitbucket pipeline YAML

I'm proficient in frontend development but new with CI/CD. Goal: Test and build a Next.js SSR project with a Bitbucket pipeline, deploy to Azure. Question: My pipeline is working, but could you give ...
• 11
1 vote
0 answers
21 views

### Optimization of React Product Page component

I was working on Product Page with its nested children. On the page we can see a specific product data, add item to the cart and set quantity which we want to add. The codebase is nasty as I only ...
• 33
1 vote
1 answer
63 views

### Extract each occurrence from an array of objects

I have a huge list of 4k+ software products. My goal is simple. I have a list of products. Each of those products has a software value. I would like to extract each software occurrence and covert it ...
• 113
4 votes
2 answers
133 views

### Srivastava multivariate Fox H function in MATLAB

I was trying to rewrite the Python code in MATLAB. The result is consistent. But, the MATLAB code is so slow. Any help would be appreciated. Ref python code link The MATLAB code written by me is as ...
• 169
1 vote
1 answer
271 views

### Rules-engine to be improved/simplified for Efficiency (performance), Extensibility and Maintenance?

This is a simple implementation of a rules engine. I am really hating the very long MATCH/CASE function. I am wondering what kind of Design Patterns could be used there to make this code more ...
6 votes
2 answers
738 views

### Lotto Number Generator - Javascript

Newbie to Javascript here and just practicing by making a random Lottery number generator. I am practicing by building simple, achievable projects. The aim of this project is to make 10 lines of 6 ...
1 vote
0 answers
42 views

### Alternative Solution for Converting Word Shapes to Images for UserForm

I am trying to convert shapes embedded in a Word document into image files so that I can display them in a UserForm. My current approach involves using Microsoft Publisher to save the shapes as image ...
• 111
6 votes
0 answers
87 views

### Optimizing SymPy Implementation of prime factorization in form of QUBO

I'm trying to reproduce a paper on Prime Factorization. This paper converts the problem into a QUBO form, which then we can map it to an Ising Minimizer. I've basically done everything and I've ...
6 votes
3 answers
185 views

### Find the number of cycles of length 3

Given the count. Find the number of cycles of length 3. Input format: The first line contains two integers n and m (1 < n, m ≤ 3✕10⁵) — the number of vertices and edges, respectively. Each of the ...
• 317
3 votes
0 answers
89 views

### Toom-3 big-integer multiplication algorithm

I am developing a C++ big integer library for C++11, 14, 17, 20, etc., as an exercise. The Toom-3 algorithm is resisting me a little bit. AFAICT, it does produce the right results but not as fast as I ...
• 201
2 votes
2 answers
172 views

### CSV Data Plotting Program in C#

I am trying to implement a CSV data plotting program in C#. In the plotting part, I use ScottPlot.NET to perform plotting operation. There are five column in the given CSV file, therefore, I use ...
• 5,466
3 votes
1 answer
108 views

### Benchmark for loop and deque/map/methodcaller

While discussing with some colleagues, one argued that a for loop over a list of objects to call a method is a bad practice because it has bad performance compared ...
• 521
3 votes
3 answers
143 views

### Efficiently generate a random position inside an outer rectangle but outside an inner rectangle

It should be a uniform distribution (ie: every point is equally as likely). I also don't want to use the simple solution of: "in a loop check to see if the current generated point is within the ...
• 223
6 votes
1 answer
387 views

### C++ program to format byte sequences into Python like string representations

This is a C++ program I wrote, that includes functions to convert integers to byte sequences in little endian or big endian order, and functions to convert a byte sequence to a string representation. ...
• 3,178
3 votes
2 answers
70 views

### Reading a file into lines (benchmarking getline() vs mmap_memchr() vs mmap_getline() vs fread())

This is a follow-up to: Reading a file into lines with mmap vs getline. The actual names of the functions are not ...
• 9,647
8 votes
3 answers
450 views

### conv2 Template Function Implementation for Image in C++

This is a follow-up question for An Updated Multi-dimensional Image Data Structure with Variadic Template Functions in C++. I am trying to implement conv2 template ...
• 5,466
4 votes
2 answers
96 views

### Golang Optimize Unzipping FiIes

I have been working on optimizing some code I use for compressing images and linting content in epub files. I originally used cli utilities to help get the job done before moving to using Go code as ...
7 votes
1 answer
234 views

### Reading a file into lines with mmap vs getline

I required a function to read a file into lines for a text editor, and ended up with two routines. One uses getline(), and the other uses ...
• 9,647
3 votes
1 answer
222 views

### Leetcode: Number of Islands - BFS (Queue vs Recursion)

I was playing around with leetcode's Number of Islands. As per the challenge's description: Given an m x n 2D binary grid grid which represents a map of '1's (land) and '0's (water), return the ...
• 341
3 votes
5 answers
2k views

### How do I speed up this simulation program

This is a program to solve a differential equation numerically using Euler method. As of now, it is very slow, and I need to run 10000 Monte Carlo simulations. The differential equation is called ...
2 votes
1 answer
135 views

### Count how many numbers in a range have exactly three divisors

The challenge Given array a of n numbers, I need to count how many positive numbers less than each aᵢ have exactly 3 divisors. Constraints 1 <= aᵢ <= 2.5 * 10¹³ In other words, the minimum ...
8 votes
3 answers
2k views

### Bug Byte puzzle from Jane Street

This is a puzzle from Jane Street. Given this graph: Fill in the edge weights in the graph with the numbers 1 through 24, using each number exactly once. Labeled nodes provide some additional ...
• 5,604
2 votes
1 answer
132 views

### Multithreaded sparse linear solver in Python

I would like to know if there are any multithreaded sparse linear solvers for LU decomposed sparse matrices. I want to increase the solving speed of a system like: ...
• 29
5 votes
1 answer
560 views

### The Wu line drawing algorithm for anti-aliased lines optimization

I need to optimize the following function with low-level optimizations (No SIMD, Multithreading). I already applied a lot of optimizations and got it ~65% faster, but it is possible to get it 200% ...
3 votes
2 answers
92 views

### Optimizing a Function to Check Pronic Numbers in JavaScript

I've written a function in JavaScript to check whether a given number is a Pronic number. A Pronic number, also known as an oblong number, rectangular number, or ...
• 523
3 votes
2 answers
58 views

### Optimizing a Function to Generate a Row of Consecutive Odd Numbers in a Triangle

I've written a JavaScript function that generates a row of consecutive odd numbers in a triangle. The triangle looks like this: ...
• 523
1 vote
2 answers
71 views

### Using odd prime powers, my heuristic tries to solve instances of Exact 3 Cover in polytime, what can be done to optimize it?

By the way, a heuristic is not the same thing as a proven working algorithm that solves all input instances. It could either be experimental or be used to study intricacies in a problem. The purpose ...
• 451
9 votes
4 answers
2k views

### Implementing a simple byte manipulation encryption

Can you kindly take a look at the code? Any suggestions regarding performance, readability, potential bugs, portability, security measures, etc. are highly appreciated. The code reads a character, a ...
• 193
3 votes
1 answer
81 views

### Pytorch code running slow for Deep Q learning (Reinforcement Learning)

I'm a new student in reinforcement learning. Below is the code that I wrote for deep Q learning: ...
2 votes
1 answer
81 views

### Determining the least dangerous tags with over 1K answers to answer

So I thought I'd take another shot at making a SEDE query after being somewhat inactive after a while. Essentially what this does is that it takes the tags that have at least 1000 answers for that tag ...
• 279
6 votes
1 answer
335 views

### Codeforces: D2. Counting Is Fun (Hard Version)

The code works okay for the following problem. Problem An array 𝑏 of 𝑚 non-negative integers is said to be good if all the elements of 𝑏 can be made equal to 0 using the following operation some (...
• 244
0 votes
0 answers
30 views

### Fastest way of finding if current user has access to a folder with Powershell

I have a Powershell script that selects a random file in a lab environment and then reads, writes, creates, and deletes files to simulate a live environment. This lab also includes folders that I don'...
• 143