Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

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.

5
votes
1answer
17 views

Primes and SemiPrimes in Binary

I'm in the midst of re-learning python. My current effort is an implementation around prime factorization. I am attempting to reproduce something similar to the table found here (in binary): https://...
5
votes
0answers
17 views

Tensorflow loop to analyze gradients derived from MRI and PET images

The code shown below takes the partial derivative of each pixel of the output fused image of a neural network with respect to input image of the neural network using tensorflow's ...
-2
votes
0answers
36 views

Looping through this list takes time [on hold]

Below is the function which takes in list containing 3million elements and then creates another dictionary out of it for further lookups. This is an extremely time consuming function which after ...
5
votes
1answer
158 views

Scraping an parsing jockeys data using Task.Run

I started to have HUGE doubts regarding my code and I need some advice from more experienced programmers and architects. On the button click, the application runs a method, that is running a ...
11
votes
3answers
1k views

Find the common ancestor between two nodes of a tree

Here is my code in Python for to find a common ancestor between two nodes in a particular tree. This is a question from Cracking the Coding Interview that I decided to implement on my own. No one has ...
2
votes
0answers
26 views

Spiral printing elements of a matrix

As I'm learning elixir, I wrote some code for printing elements in the spiral of a matrix(2D array). I was wondering if there is any room for improvements with regards to its performance or ...
2
votes
2answers
193 views

Regex version of strip() - Ch. 7 Automate the Boring Stuff

Here is a practice exercise — Regex version of strip() \$-\$ Write a function that takes a string and does the same thing as the ...
4
votes
2answers
321 views

Fantasy game inventory — Ch. 5 Automate the Boring Stuff

Here is a practice exercise — Fantasy Game Inventory \$-\$ You are creating a fantasy video game. The data structure to model the player’s inventory will be a dictionary where the keys are string ...
3
votes
0answers
39 views

msmq bulk send in c# [on hold]

Please review the code below and provide constructive feedback to improve. Multiple threads call the SendMessageToMSMQ method to send messages to a msmq queue. ...
4
votes
1answer
44 views

Java Mandelbrot Set Viewer

I'm writing my own version of a Mandelbrot set generator, with pan and zoom functionality. (There's not yet a color overlay of sets generated with various beta values; the beta value is changed ...
3
votes
0answers
62 views

Alternative for VLOOKUP/Index-Match in VBA

I am sharing this function I wrote with the community to provide an alternative to slow VLOOKUP and/or Index-...
4
votes
1answer
45 views

Collecting all relevant data from xlsm files

Is there a way to speed this guy up? The code is designed to go into a directory, open up all of the .xlsm files in the folder, and copy specific data into a target file. This code works as is, but it ...
0
votes
2answers
55 views

(Leetcode) Valid parentheses

This is a Leetcode problem - Given a string containing just the characters '(', ')', '{', ...
6
votes
2answers
71 views

Positive cumulative sum of difference

I have a water reservoir with input and output rates. I want to determine when the input is exceeding the output by a certain constant. To accomplish this, I need to cumulatively sum all cases where ...
3
votes
1answer
57 views

Most efficient way to check if user is allowed to update an object

So I have an user which can create his own Locations. I implemented a webservice in order to add and update locations. If the user is not the owner of the location i want to throw an appropriate ...
1
vote
2answers
40 views

Leetcode 15 - 3 sum

This is a Leetcode problem - Given an array nums of n integers, are there elements \$a, b, c\$ in ...
2
votes
0answers
16 views

Whiten black contours around a skewed image

I have this image: I want to whiten the black contours (borders) around it without affecting the image content. Here is the code I used: ...
3
votes
0answers
31 views

Strongly Connected component algorithm implementation(Python)

My goal is to implement Strongly Connected Components algorithm using python. I have splitted up my code on 3 parts: Data Load: ...
7
votes
2answers
436 views

Word-Ladder solver in Python 3

Follow-up to Python program to find a word ladder transforming "four" to "five" I'm trying to write a program to solve a word ladder puzzle to brush up on my Python. For those who ...
3
votes
0answers
26 views

(Leetcode) Snakes and Ladders

This is a Leetcode problem - On an \$N\$ x \$N\$ board, the numbers from 1 to N * N are ...
5
votes
0answers
45 views

SQS subscriber pattern in background service

I have the below code to pull messages from a FIFO SQS queue. Using the while (IsRunning) loop makes me feel to question the code design. Is there a pattern I am ...
4
votes
1answer
71 views

Two ways of implementing a combat system

Below is a segment of a game I am writing to stay in practice with my Java. EDIT The class this method is in is the Encounter class. This class just manages the encounter between the player and an ...
-2
votes
0answers
30 views

Best way to implement Account verifiction [closed]

So I am having a discussion with a friend of mine whats the best way to verify an account. We have come up with two methods: Method 1 The first method there are three steps: register user and ...
4
votes
4answers
122 views

Find the nth term of a sequence that consists of Fibonacci and prime numbers interleaved

I have given a series problem 1,2,1,3,2,5,3,7,5.... in which the odd terms forms the Fibonacci series and even terms form the prime number series. I have to write a code in which I have to find the ...
2
votes
1answer
40 views

Select optimal piecewise regression fit

I'm making a program which fits a piecewise linear regression with up to 4-5 breakpoints in the data, and then deciding how many breakpoints is best to prevent over and underfitting. However, my code ...
3
votes
1answer
54 views

Most efficient way to loop through files using VBA Excel

I have a procedure for looping through all files in folders and subfolders starting at a folder which the user can select. The user can select both the source and target folder. I'm using Excel VBA ...
2
votes
1answer
51 views
4
votes
1answer
53 views

Pick the best combination of n choose k models

Algorithm Let \$M_0\$ denote the null model which contains no predictors. This model simply predicts the sample mean of each observation. For \$k=1,2,\ldots,n\$: Fit all \$n \choose k\...
3
votes
1answer
46 views

Optimizing Luhn check digit algorithm

The internet as a whole and Code Review in special already provide a decent amount of implementations of the Luhn check digit algorithm. They often follow a relatively "naive" strategy, in that they ...
3
votes
1answer
47 views

LeetCode: Transpose Matrix C#

Please review performance https://leetcode.com/problems/transpose-matrix/ Given a matrix A, return the transpose of A. The transpose of a matrix is the matrix flipped over it's main ...
6
votes
3answers
264 views
+50

Calculating time windows for entities

I have made some code that operates on multiple entities and creates 'time windows' for them. Basically, the entities will contain states, usually in boolean or int. They will be timestamped and in ...
0
votes
2answers
118 views

(Leetcode) Brick wall

I would like to know whether I could make my solution to this Leetcode challenge much faster. There is a brick wall in front of you. The wall is rectangular and has several rows of bricks. The ...
7
votes
2answers
877 views

Arranging numbers in a circle such that the sums of neighbors and sums of diametric opposites are prime

I need to create a circle with numbers from 1 to n , however it is necessary to respect some rules: All numbers from 1 to n are used in the circle only once. The sum of two consecutive numbers ...
5
votes
0answers
58 views

Neural Network with Template Metaprogramming

I was implementing a simple neural network, and I noticed that, if I ever wanted to change the layers' activation functions, i would have had to completely rewrite some parts of the code, so I tried ...
2
votes
1answer
71 views

Periodically sending data from database to an API

I'm trying to make a timed background service in .NET Core (I found this approach in Microsoft Docs), that every 15 seconds it gets data from the database (1000 rows max, if something exists) then ...
15
votes
3answers
464 views

Razzle Dazzle simulator

Inspired by the video from Scam Nation and James Grime from Numberphile, I tried to make a Razzle Dazzle simulator. Razzle Dazzle is a scam in the form of a game. Per turn, the player pays a fee and ...
3
votes
0answers
36 views

Optimising Probabilistic Weighted Moving Average (PEWMA) df.iterrows loop in Pandas

I'm implementing the Probabilistic Exponentially Weighted Mean for real time prediction of sensor data in pandas but have issues with optimising the pandas notebook for quick iterations. Is there a ...
2
votes
0answers
34 views

Retrieve file and other input fields from JavaScript to send to ASP.NET Core

I am currently developing an e-commerce website where users can upload their photos to customise their products. The use case begins when the user selects a product from our website (e.g. shirt). ...
4
votes
2answers
76 views

SIMD Mandelbrot calculation

I was messing around with GPU compute shaders the other day and created a Mandelbrot shader. Unfortunately, Metal doesn't support double-precision in compute shaders, so beyond a certain zoom level, I ...
26
votes
5answers
3k views

C++ logging library

I am creating a logging library in C++, and I wanted your opinion on code quality and performance within some methods. You may ask why yet another logger - the answer is simple. This logging library ...
1
vote
1answer
70 views

(Leetcode) Freedom Trail

I would like to know whether I could make my solution to this challenge shorter and more efficient. Below is the description of the challenge (this is a Leetcode problem) - In the video game ...
5
votes
2answers
94 views

Improving particle performance in P5.js

I have modified a particle system to create an effect similar to the one that I want. However, with any substantial amount of particles it performs very slowly on my laptop (around 1.7 fps at the ...
2
votes
1answer
37 views

(Leetcode) Perfect Rectangle

This is a Leetcode problem - Given \$N\$ axis-aligned rectangles where \$N\$ \$>\$ 0, determine if they all together form an exact cover of a rectangular ...
2
votes
1answer
78 views

Find String white spaces indices

This function return all white spaces indices as an array of Integer , and it's work just fine with small string : ...
5
votes
4answers
353 views

Printing Pascal’s triangle for n number of rows in Python

I have written a program that takes a number n and prints Pascal's triangle having n number of rows. Here is my code - ...
6
votes
1answer
84 views

Choosing evenly distributed points from a million points on a sphere

I have \$10^5\$ to \$10^6\$ points on a sphere, and want to choose some points from them which are as close as uniformly distributed as possible. For that reason, I do the following: at each step I ...
4
votes
1answer
42 views

Gravity simulation using Numpy and Pygame

This is a simple gravity simulator coded in Python 3.7 using Numpy and Pygame. I was wondering if it can be optimized further. Initially I had coded it using pure Python lists, using nested loops to ...
7
votes
1answer
62 views

Parallel Ramanujan's formula for 1/π calculation

I finished my university project for calculating \$1/\pi\$ and I would love to get some feedback. Before you guys jump into this code please keep in mind newcomer to C++ just decided to use it for ...
0
votes
1answer
53 views

Optimize this code of adapter's overriden method getItemCount() [closed]

How can I optimize this code of adapter's overriden method getItemCount() into simpler form? ...
4
votes
1answer
78 views

The Dungeon game

This is a Leetcode problem - The demons had captured the princess (P) and imprisoned her in the bottom-right corner of a dungeon. The dungeon consists of M x N rooms laid out in a 2D grid. Our ...