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
4
votes
1answer
53 views

Game of Life state calculation in javascript

I've created a Life implementation in javascript with the goal to be as fast as possible, with the rendering I'm satisfied (see picture bellow), hovever the next state calculation is really slow and I'...
1
vote
0answers
24 views

Rolling average over predictions

I am using a Deep Learning model I trained and want to improve its accuracy by implementing a rolling average prediction. I have already done it but want to improve it as I am making predictions on ...
3
votes
1answer
43 views

Number of inversions on a segment (Help for optimisation)

So I was tryna do this question and I get TLE on one the test cases (the actual link to the question will ask you to login) What is an inversion ? An inversion of an element is the number of ...
1
vote
0answers
29 views

Algorithm to find bucket and item indices from power of two bins?

So this is building off of Algorithm for dividing a number into largest "power of two" buckets?. Here is a slight modification of the answer from there: ...
1
vote
2answers
47 views

Regex to match each line in a file, with windows and/or linux line break included, even for missing line break at EOF

My requirement is to match each line of a text file, including the line terminator of each, at most excluding the terminator of the last line, to take into account the crippled, non POSIX-compiant ...
2
votes
1answer
47 views

Data-type implementation for multiple dynamic histograms

This is almost exercise 3.2.14. from the book Computer Science An Interdisciplinary Approach by Sedgewick & Wayne (since I am self-studying, I changed it a little bit): Develop a version of ...
7
votes
3answers
252 views

Priority based categorization using pandas/python

I have invoice and code data in the below Dataframes Invoices ...
1
vote
0answers
22 views

Trying to speed up VBA macro to generate viable Daily Fantasy Sports lineups

I have created the code below to generate daily fantasy sports lineups from a pool of players that have been entered in my excel file. Right now the code can run through about 16,500 combinations per ...
1
vote
1answer
43 views

Network flow analysis

I've created a short Python script in order to do some analysis on network flows. I have an inventory of networks (/8 to /30 masks) of medium size (around 10k references) that provide several ...
3
votes
0answers
41 views

Simple chess engine in Python

I have programmed a chess AI in python as a first project to learn both Python and the inner workings of a chess engine and wanted to have some input on syntax, code efficiency and any tips in general ...
3
votes
1answer
77 views

Mergesort in python

My mergesort implementation currently takes a very long time, for a list with 1 million elements it takes over 130 seconds to get the list sorted. Could someone kindly have a look at my code and ...
5
votes
3answers
153 views

Project Euler #645 — speed up Monte-Carlo simulation in Python

I am trying to solve Q645. While the logic used for my code seems to be appropriate, the code itself is way too slow for the large number required in this question. May I ask for suggestion(s) to ...
9
votes
4answers
2k views

Algorithm for dividing a number into largest “power of two” buckets?

For example, these are expected outputs: 3: 2, 1 4: 4 5: 4, 1 6: 4, 2 7: 4, 2, 1 8: 8 9: 8, 1 ... 20: 16, 4 ... 25: 16, 8, 1 ... 36: 32, 4 ... 50: 32, 16, 2 Up to ...
4
votes
1answer
93 views

Find first index of 1

Given a sorted array consisting 0’s and 1’s. The task is to find the index of first ‘1’ in the given array. I submitted the below code in geeks for geeks and the execution time is 5.77. Need help in ...
10
votes
1answer
153 views

Generating colorful Mandelbrot and Mandelbar set wallpapers

The following is the program 3.2.6. from the book Computer Science An Interdisciplinary Approach by Sedgewick & Wayne: ...
-1
votes
1answer
49 views

Optimise python functions for speed

Any one can help me optimise those three functions? I did profiling and timing of my original python file and found that most calls and time duration was because of those three functions. The three ...
-4
votes
1answer
43 views

What is the time complexity problem I need to manage on a Hackerank “Ransom Note” - my code runs perfectly [closed]

I am trying to solve the "Ransom Note" problem on hackerank. Why isn't my code getting submitted? What can I do differently? is my total time complexity, in this case, it is O(n^2)? ...
2
votes
1answer
42 views

Get exactly `n` unique randomly sampled rows per category in a Dataframe

I want to get exactly n unique randomly sampled rows per category in a Dataframe. This proved to be involve more steps than the description would lead you to ...
5
votes
1answer
58 views

Handle (“potentially” occuring) scalar-Vector and Vector-Vector operations

I'm looking into fixing some obvious performance-related issues in my code but I tend to employ bug-introducing tricks as I do so. My code uses a library which defines ...
2
votes
2answers
102 views

Text Normalizer

I am working on a text normalizer. It works just fine with small text files but takes a very long time with large text files such as 5 MB or more. Is there anything to change in the code to make it ...
3
votes
2answers
78 views

Is the following divide and conquer recursive algorithm for the exponentiation more efficient than the iterative one for large numbers?

I have the two following algorithms. My analysis says that both of them are \$\mathcal O(m^24^n)\$ i.e they are equivalent for big numbers (more than 32 bits). Is this right? Note that ...
2
votes
2answers
56 views

Dynamic Array Based Stack in C

I wrote a dynamic stack in C that uses an array as a structure. I tried to maintain O(1) for push and pop and believe I have done so. I want to know what can be written in a cleaner way and if there ...
4
votes
1answer
77 views

Multiple Pandas Ranking Operations within a Loop - Better Optimization and Performance

I have implemented the following code which works as intended. However, I would like to improve my code in terms of performance and efficiency Code in Question ...
5
votes
1answer
134 views

Drawing a Thue-Morse pattern recursively

This is web exercise 3.1.63. from the book Computer Science An Interdisciplinary Approach by Sedgewick & Wayne: Write a program that reads in a command line input N and plots the N-by-N Thue-...
2
votes
0answers
35 views

Multiple circle - line crossing performance

So I made a game during the pandemic, and I really enjoyed seeing it grow and learn a ton of stuff and implement it.. The game is about small moving circles that cross a line and when they intersect ...
2
votes
1answer
52 views

Implementing toggle button using Qt

I have below code for implement toggle button. After including below code, processing power consumed over 90% in my embedded application. Is there any way to reduce this processing power. ...
0
votes
0answers
62 views

Kattis: “watering Grass” Interval covering problem, why is my code so slow?

im currently practicing, doing a python implementation of this challenge: https://open.kattis.com/problems/grass Problem described here: ...
2
votes
0answers
29 views

Insertion sort for std::forward_list

I'm practicing writing insertion sort for std::forward_list. But I find myself creating many variables and using many if statements. Looking for inputs on how to make the function more efficient, ...
15
votes
2answers
2k views

C++ chess game engine using Minimax and alpha-beta pruning;

My chess game is over, everything has been finished, except for some special (like en passant)moves. The main part of the game is its engine which I have coded using the Minimax algorithm with alpha-...
2
votes
0answers
25 views

Random filling of a general matrix

This problem has been hard to model and understand, however, here we go: \begin{gather} \text{Let } R_G = (A_{m \times n},f_n)\\ \end{gather} such that: \begin{align} A_{m \times n} &= \...
2
votes
0answers
21 views

Profiling redis RTT in go

I'm trying to determine best case round-trip times to a redis server. Particularly, I am trying to determine exactly how low I can get the latency on a local instance. On a technical level, this is ...
5
votes
4answers
151 views

C++ program to find first 10 amicable numbers

I took it as a challenge to write a C++ program to find the first 10 amicable-numbers. Amicable numbers Let's take 4. What are the proper divisors of 4?. They are 1 and 2. Their sum is: 3. Now let's ...
1
vote
1answer
32 views

Pandas : Apply Merge operations from a column

I have a data frame, which contains three columns: ...
5
votes
1answer
140 views

Scan-line algorithm to fill in a triangle

I wrote the following script to fill a Triangle. ...
2
votes
2answers
69 views

Common Unit Testing Code – Follow Up

This question is a follow up question to the Common Unit Testing Code portion of my lexical analyzer questions. My primary concern is the code in the header file and the C source file that implements ...
1
vote
2answers
77 views

Better way to calculate double-scattering diffraction using cartesian product of arrays?

This script calculates points in reciprocal space for hexagonal 2D lattices, then uses the cartesian product from itertools to add each vector from one lattice to all of the vectors of the other in ...
4
votes
2answers
59 views

Move two element of an array to the front - Javascript

I want to move two element of my array to the beginning. This solution works but I would like to know a better approach since using sort() twice is probably not the best. Array Input: ...
9
votes
2answers
1k views

Can I draw a square with pixels more efficiently?

I'm drawing a square on a window using an implementation of Xlib. I put a colored pixel with my_pixel_put at a specific (...
3
votes
0answers
43 views

Reorder the Columns in a CSV File in Descending Order

I wrote a script to reorder the columns in a CSV file in descending order and then write to another CSV file. My script needs to be able to handle several tens of millions of records, and I would like ...
3
votes
1answer
104 views

Automate the Boring Stuff – Chess Dictionary Validator – Optimal Solution

Brief introduction: so the point of the question is that the author doesn't really talk about good or bad code quality and I really wanted some feedback to have a grasp of how the code for others to ...
5
votes
1answer
68 views

Hand Coded State Driven Lexical Analyzer in C With Unit Test Part C

This review is presented in 3 questions due to the amount of code: Part A contains the Lexical Analyzer and the main portion of the unit test code. Part B contains the lower level unit tests called ...
4
votes
1answer
38 views

Hand Coded State Driven Lexical Analyzer in C With Unit Test Part B

This review is presented in 3 questions due to the amount of code: Part A contains the Lexical Analyzer and the main portion of the unit test code. Part B (this question) contains the lower level ...
8
votes
2answers
105 views

Hand Coded State Driven Lexical Analyzer in C With Unit Test Part A

This code review is presented in 3 questions due to the amount of code: Part A (this question) contains the Lexical Analyzer and the main portion of the unit test code. Part B contains the lower ...
0
votes
1answer
43 views

Efficiently performing multiple nested grouping and mapping in Javascript

I have an array of log objects with log_types and dates, like this: ...
2
votes
0answers
44 views

Optimal Caching - “Farthest in Future” Algorithm

I'm looking for someone to really tear apart the following code I wrote for my graduate-level algorithms class. The problem was Optimal Caching, and the algorithm I'm implementing is called "...
7
votes
5answers
2k views

Egg size Prompt Box

So I am currently doing an Assignment where I have to make a code that when someone opens the page, they input the weight of an egg and it comes back with what "size" it is. I got the code ...
3
votes
0answers
28 views

Performance and abstraction questions re: scraper for carfolio.com

I'm a new Rust programmer, primarily coming from Ruby experience. I started working on a small project to scrape vehicle specifications from https://carfolio.com I chose to write it in Rust and ...
2
votes
0answers
53 views

Custom MediaController with full screen video image option

I have overridden setAnchorView() of MediaController class to display full screen option icon using below code.The code seems to be working fine in devices I tested but I have few doubts for which I ...
2
votes
0answers
51 views

How can I shorten the runtime of my simulation?

Before you read the code below, note the following explanation: I have three classes: Driver, Vehicle, and ...
2
votes
0answers
51 views

Allowing a user to draw their own avatar

I am working on a turtle project where the user can draw their own avatar. The thing is, I want the user to be able to decide whether the turtle they drew will be filled, or not. The filled part is ...

1
2 3 4 5
154