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.

Filter by
Sorted by
Tagged with
2
votes
2answers
67 views

Generating prime numbers quickly in rust

I am attempting to re-implement a postponed sieve algorithm for generating prime numbers in Rust. I am able to make a solution that works, but I have to use a couple of ...
3
votes
2answers
408 views

How do I increase the speed of this loop or pixel color finding process?

I've been working on a program that should find the color red on the screen and then send out an alert. The issue is that the red color moves around a lot and the color finder moves too slow on the ...
1
vote
0answers
79 views

Python functions to serialize nested data structures human readably

See Serializing (nested) data structures in a human-readable format for more details. In the last two days I have significantly improved my function, and wrote seven implementations of it. I have ...
2
votes
1answer
51 views

Generating a matrix with each row having normalized weights

I just asked this question over Stack Over Flow on how to improve my code and reposting it here as someone on Stack Overflow recommended this platform. I have written two python functions and they are ...
2
votes
2answers
388 views

How to avoid excessive for loops in C++ [closed]

I have been trying to write a small test program and I was trying to think of any potential optimization I could do, especially if there is any chance to avoid some of the for loops. The program has ...
1
vote
1answer
44 views

Calculate correlation of genes stored in dataframe rows

This script is to calculate the Spearman correlation of genes that are stored in rows of a pandas dataframe. The original df has around 2000 row names. With my current code, this requires 2000*2000 ...
2
votes
2answers
81 views

Serializing (nested) data structures in a human-readable format with all bugs fixed

See Serializing (nested) data structures in a human-readable format for more details. This is the latest version, I have fixed all bugs and now this piece of code works completely as intended. And I ...
-1
votes
4answers
87 views

Python weighted choosing that works with very large numbers

I have written a function to choose randomly with weights from very large data sets in which the weight of elements can be several thousands. The input of the function is a flat ...
1
vote
0answers
12 views

Mean and variance of element-wise distances in a set of multi-dimensional arrays in Matlab - follow-up

This is a follow-up question for Calculate distances between two multi-dimensional arrays in Matlab and Mean and variance of element-wise distances in a set of multi-dimensional arrays in Matlab. For ...
4
votes
2answers
763 views

Serializing (nested) data structures in a human-readable format

I am reinventing the wheel to write a function that serializes a (nested) data structure human readably. The default output is deliberately similar to that of ...
5
votes
1answer
178 views

Optimized way to save list of files

I would like to optimize the way that I save files. Each second I save lots of strings in different files. What I want to do is bunch up these IO tasks so they happen in bursts, instead of spread out ...
2
votes
1answer
32 views

Recursion to generate fractal

I used recursion to generate fractal and got the desired result but I think my code can be better I started using MATLAB a few days ago and since than trying and learning new things. Now this code ...
3
votes
0answers
50 views

Implementation of a crypto formula in Python

I need to implement in Python the formula in the image. The set B is a set of real numbers \$-1 \le t \le 1\$. Also, \$\mathbb{F}_2\$ is a set with the elements 0 and 1. \$y_i\$ is the \$i\$-th ...
0
votes
2answers
95 views

Little program to measure the 'cost' of CPU-operations

This is a follow-up on my first question, Little program to measure costly operations, thanks for all answers and comments, esp. @JDługosz. I made a second attempt adapting a teaching program I found ...
2
votes
3answers
86 views

Leetcode First Unique Character in a String code optimisation

I was working on First Unique Character in a String Question Given a string s, find the first non-repeating character in it and return its index. If it does not exist, return -1. Example 1: ...
1
vote
3answers
120 views

Count how many iterations of deletion until array is ordered

I'm trying to write a program whose input is an array of integers, and its size. This code has to delete each element which is smaller than the element to the left. We want to find number of times ...
1
vote
2answers
65 views

Little program to measure costly operations

I want to learn about performance impact of different calculations and influences/optimizations like compiler flags, use of SSE, AVX etc. I'm going to code some small subroutines which will take place ...
2
votes
1answer
39 views

iterating a big list of objects throws a memory issue

I'm writing a function which iterate through a list of objects and should return: true if all the items have the attributes (cp and type). false if all the items haven't the attributes (cp and type). ...
7
votes
4answers
1k views

Benchmarking data copying

I got inspired by a recent question to do some benchmarking on the different methods to copy data and this is what I have come up with: ...
0
votes
2answers
95 views

Calculate square of (sum of even-indexed) - (sum of odd-indexed) subarrays from an array

Find all subarrays from a given array in the least possible time complexity. Requirement: calculate the square of (sum of even-indexed elements) - (the sum of odd-indexed elements) of al the subarrays....
2
votes
1answer
90 views

Drug Analyzer challenge

What do I need help with? I'm doing the challenge below, in which I need to increase code performance. It's currently at 63% and I need to increase it to at least 71% however I can't optimize more ...
2
votes
1answer
67 views

replace substrings from within Hebrew text

I have a string of Hebrew text which also contains":", "-", & "|". Attempting to replace "-", "|", and ":" with a space. How can I do ...
0
votes
1answer
47 views

custom array sorting algorithm

So I came up with a "new" sorting algorithm: ...
3
votes
1answer
74 views

Segmented Sieve of Eratosthenes with wheel factorisation

Problem I have a project in which I implemented variants of the Sieve of Eratosthenes as well as benchmarking and profiling harnesses for these (which can be ran with ...
-2
votes
1answer
91 views

A custom trading strategy

I am currently finalising the class for a trading strategy and wanted to know if the below could be re-written in a shorter way that will let it run faster? This is PCA1 df: ...
1
vote
1answer
70 views

Prevent Column Name Collision

I have been working on a series of posts about a library to connect to databases but most of the scenarios I have to resort to some "JOIN" the problem arose when two or more tables had some ...
4
votes
1answer
89 views

Gear Shift Indicator using Hall Effect Sensors & 8x8 LED Display

I wired up a Gear Shift Indicator for my dad's car to display what gear it is currently in, and showing changes with animations (sliding up and down as appropriate, with a few bonus ones for fun at ...
0
votes
1answer
62 views

Recursive function that gives the number of hashes present in a Merkle Mountain Range proof

I have written a function that gives the number of hashes present in a Merkle Mountain Range proof. Using Solidity, this function can be written as: ...
3
votes
2answers
355 views

Asynchronous and recursive word square generator in C#

Overview I've created an asynchronous and recursive method of generating word squares, of any size (known as the order of the square), from a known word list. If you're unfamiliar with word squares: ...
0
votes
0answers
21 views

API handler to retrieve universities from MongoDB

I have this handler for my API endpoint /api/universities. My main concern is the overall quality of the code and the efficiency of my use of ...
2
votes
1answer
47 views

C++ allocator for std::wstring_convert

In my application, I'm using std::wstring_convert to convert std::string into std::u32string....
6
votes
2answers
152 views

A string separator that doesn't separate if in quotes

The sep function separates string by the characters of seps, but it escapes the separates ...
2
votes
2answers
89 views

Algorithmic Efficiency: GetShortestUniqueSubstring implementation

I came upon this Youtube video and the problem they discussed piqued my interest, so I decided to take a stab at it. Below is the question: Given an array of unique characters ...
2
votes
4answers
935 views

Fantasy Character Creation Tool (early prototype)

I recently started studying C++ programming; while attending the course I'm writing a program on the side as a personal project to familiarize with what I'm learning. It is still very basic and I'm ...
1
vote
1answer
43 views

Data processing with the CERN ROOT framework

Problem. I have a directory of .root files (the proprietary format of CERN's ROOT framework). These files contain so-called <...
3
votes
2answers
117 views

Sorting worksheet by a given column

My code runs exactly as it should. However, I would like to make it run a bit faster. I have tried defining some variables as Long to run it faster but it is still ...
4
votes
2answers
133 views

Prioritise injured cats for treatment (dictionary/map search optimization Python and C++)

I am once again attempting another CP problem, and I have ONCE AGAIN run into an optimization issue because of the time limit of one second: https://open.kattis.com/problems/doctorkattis It is common ...
2
votes
1answer
49 views

Python: lru_cache make leetcode's dungeon game more slower

I'm trying to implement a recursive+momoize version for leetcode's dungeon game question. I tried to use @lru_cache(): ...
5
votes
1answer
78 views

The python code simulates an environment of a disease and calculates how many people get infected

The python code simulates an environment of an X number of persons with an Y number of places they can go to, puts the persons randomly in the places and calculates how many persons get infected, die ...
1
vote
2answers
67 views

Improving Project Euler code problem #10

So, I just finished Problem 10 on Project Euler, but it took about 3 to 4 minutes for my output to come out, due to bad coding, I guess, any suggestions on how could I optimize my code? Question The ...
0
votes
0answers
61 views

Better Approach for the House Robbery Problem (LeetCode 198)?

The problem states that you have to rob the maximum money stashed in the houses but you cannot rob two adjacent houses. array[i] denotes the money in the (i)th house. I got the following code ...
4
votes
4answers
631 views

Tic Tac Toe in C++ with classes

My first language is Python and I learned considerably a good amount of it. So now I started learning C++. I know the basics of C++ and about classes and inheritance. This is my first serious project ...
4
votes
1answer
84 views

Reduce multiple re rendering of components in React

Following is my working application that contains a Search Container, a Sorting Container and a listing Container. Based on Search and Sort the listing data changes in the listing container. The ...
0
votes
1answer
53 views

Transformations on a game board represented as a bitset

I'm using a long as a bitset to represent a game board. If a field is set (X) the corresponding bit is set, if it's empty (...
2
votes
0answers
26 views

Python code that is unzipping files

I have a small program that is creating a counterpart of existing data files, unzips them and then changes the names of the files. This process runs on a remote desktop server (windows). I have one ...
5
votes
3answers
360 views

Software ECC embedded with a parallel NAND Flash interface

I'm developing an embedded solution (STM32L4R5 MCU - Cortex-M4F: 120 Mhz / 640 kb of ram) featuring a parallel NAND Flash (MICRON) interface and my platform lacks hardware ECC computation powerful ...
5
votes
2answers
123 views

2048 in Python Pygame

I built 2048 in Python with Pygame and it works as expected. I wanted to know where I could - Optimize the performance. Improve the UX. Or just improve the code readability. My file directory - <...
2
votes
1answer
46 views

Finding the difference in one column in a Pandas GroupBy

I am trying to calculate the time difference between samples that a satellite takes at the same location. I have data currently in a Pandas DataFrame that has latitude, longitude, and time of the ...
0
votes
2answers
62 views

Sort table with ascending or descending order without a library

This is my first day coding, and I need help with sorting a table in ascending/descending order. The idea is that when a column is clicked it will sort in ascending order, and then it is clicked again ...
1
vote
1answer
94 views

Rock paper scissors coding assignment

I had a coding assignment to write a Rock Paper Scissors game. The main task is not to show a solution but rather to test the coding style. The rules are such: Problem: rock is "O", paper is ...