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
1
vote
1answer
38 views

Project Euler # 29: Distinct powers in Python

Consider all integer combinations of ab for 2 ≤ a ≤ 5 and 2 ≤ b ≤ 5: 2 ** 2 = 4, 2 ** 3 = 8, 2 ** 4 = 16, 2 ** 5 = 32 3 ** 2 = 9, 3 ** 3 = 27, 3 ** 4 = 81, 3 * 5 = 243 4 ** 2 = 16, 4 ** 3 = ...
1
vote
0answers
23 views

Project Euler # 28: Number spiral diagonals in Python

Starting with the number 1 and moving to the right in a clockwise direction a 5 by 5 spiral is formed as follows: ...
5
votes
2answers
120 views

PLINQ code analysis in terms of efficiency of cryptographic hashes generation

I have the following code that I wrote in order to find the correct password by generating hashes out of all possible combinations and comparing each of them with the target. I'm trying to make ...
4
votes
2answers
201 views

Parser for STL stereolithography data files [closed]

I'm parsing STL files to load the coordinates. My code is: ...
3
votes
1answer
61 views

Ajax function with a callback

I have Ajax function with a callback which fetches all the Patient data however I have some perfomance issues and trying to figure out what it might be, does anyone have idea? That's my Code ...
3
votes
1answer
74 views

Hurst Exponent calculator

I am aiming to compute the Hurst Exponent of a 1-D signal time series in Python. For now, I have one existing function hurst(sig) which returns the Hurst exponent ...
1
vote
0answers
58 views

Managing millions of objects in a MMO game server [closed]

A litle context: This game server is coded entirely on C-with-classes (plain C code using basic C++ features like classes, templates and such, to avoid any possible overhead). At startup the server ...
3
votes
1answer
109 views

Collecting numbers in ascending order

What kind of algorithm wold solve the following problem from https://www.ohjelmointiputka.net/postit/tehtava.php?tunnus=junar ? I have been given a positive integer n. Take the n first positive ...
0
votes
1answer
44 views

Triangle of numbers maximum path - Greedy algorithm Python

A triangle of numbers path maximized using a greedy algorithm. It's not the most efficient way since I'm a beginner this is the best I could do. I need your feedback on how to make it better in terms ...
3
votes
1answer
69 views

SQL queries in a dataframe

I want to get table names and column names from queries in a dataframe. The dataframe is like this: ...
3
votes
1answer
62 views

Converting string of hex values to numpy array of specific shape

I am working on a project that needs to take a .bdf font file and turn it into a Numpy array. I am using the code below to turn the bitmap for the font into a numpy array. It currently works, I just ...
6
votes
1answer
85 views

A straightforward method for computing the Binomial probability mass function

I've been writing up code to test an alternate way of calculating the Binomial probability mass function. The Binomial random variable is the number of heads out of N coin tosses with coins that have ...
3
votes
1answer
62 views

Compare performance of Concurrent Dictionary with Dictionary+Locks

I wanted to measure the performance of Concurrent Dictionary vs Dictionary+Locks in a multithreaded environment. So I created my own SyncDict class of type...
7
votes
1answer
209 views

alternative to std::vector<std::function<…>> which uses tail recursion

An alternative to std::vector<std::function< >> which uses tail recursion to optimize calling the functions sequentially. I'm using this on a real-time ...
1
vote
0answers
17 views

Splitting torch tensor by flags

Working with PyTorch tensors, I need to split the batch of items by its flags, so the items in x_batch_one and x_batch_two are ...
2
votes
0answers
30 views

.htaccess file to enable compression, send security headers, and set cache expiration

This is the current .htaccess configuration for one of the website projects that I am working on, just as a learning exercise. This is working code and everything in it seems to be ok, My hosting ...
-1
votes
2answers
72 views

Project Euler problem # 3 is this the most efficient approach in Python or can I do better?

The problem statement: The prime factors of 13195 are 5, 7, 13 and 29. What is the largest prime factor of the number 600851475143 ? This code takes 9 seconds!, is there a better way? ...
2
votes
3answers
132 views

Modeling, view and projection transformation using vector and point in homogenous form

I know this is horrible code. This program is for performing modeling, view and projection transformation. The program reads input from scene.txt and outputs the <...
2
votes
1answer
50 views

Beautifulsoup and lxml (xpath) too slow with respect to regex when parsing HTML

I agree that using regex to parse HTML is not a good way, in particular I am worried about their fragility with respect to change in the HTML. The problem is that any alternatives are really too slow....
1
vote
3answers
77 views

Optimizing primes generating program in C++

I am writing a program to generate primes in range 1 upto 10^9 but it seems to be timing out. It implements the Sieve of Atkin I have tried optimizing my code using bitsets and pragmas. Please are ...
2
votes
2answers
113 views

Performance issues with double for loops, EM-algorithm

The alpha that I create is not created in a crazily efficient way I know, but the main bottleneck in this code is in what I call the "Maximization step" (see comments in code). There are double for-...
1
vote
5answers
85 views

PHP function to obtain model_name from Namespace\To\ModelName

Would there be a more clear/efficient way to write ...
3
votes
1answer
43 views

Find a Sum of Particles in A Set of Boxes Given a Number of Rows and Columns

This is a code challenge, from Codewars, the details of the specific challenge in depth can be found here: https://www.codewars.com/kata/magnet-particules-in-boxes/javascript. The summary of it ...
4
votes
1answer
79 views

Optimising iteration and substitution over large dataset

I have the following code: ...
0
votes
1answer
52 views

Nested list performance tuning

I need to make a function like these two, but at least an order of magnitude faster in python. Any tips or tricks? These functions inputs are nested lists, like: ...
-2
votes
1answer
57 views

Bodyless Self-Closing *for* Loop [closed]

I use self-closing bodyless for loop to quickly find an element within an array or collection. Learned it from a Java teacher. But I'm seeing warnings on certain IDEs that have a code inspection tool. ...
3
votes
1answer
109 views

Find A Series of Numbers Who when Squared and Summed are equal to a given Square

I am working on a CodeWars titled 'Square into Squares. Protect trees!' it can be found here: https://www.codewars.com/kata/54eb33e5bc1a25440d000891/train/javascript I have a working solution, the ...
0
votes
0answers
107 views

Minimum sum of elements, taken 2 at a time

Update: I had not recalled the question correctly and ended up with the wrong question. I have now updated the question and the solution: The question is: Given an array of integers say [8,4,6,12,10] ...
6
votes
1answer
55 views

Border Radius Preview Tool

I am running through an app idea to help improve my knowledge of Javascript. The code attached performs the following: Performs a regex on the input field to check it is value 0-9 If not, it clears ...
1
vote
1answer
124 views

Two solutions to 2-sum

I have written a solution for two sum problem in variation. first is simple with two loops and another one is one loop and hash map. But I wonder why the simple solution is faster than the efficent ...
4
votes
3answers
2k views

Palindrome test

This is some code that determines if a string of characters is a palindrome or not. My professor says that there is a performance issue with the program, but I can't quite put my finger on it. Can ...
3
votes
1answer
130 views

Simple sharding of delimited files to more sophisticated

A while back I came across the issue of having a large delimited file where I wanted to simply parallelize my python code across each line of the file. However, doing so all at once either took up too ...
4
votes
3answers
117 views

Fast-resizing uint8 buffer

I wanted a buffer like std::vector<uint8_t> which is very fast at resizing, and it does not require byte initialization (it resizes to 16K, then to 2-4 bytes, ...
1
vote
1answer
135 views

HackerRank Code “Determining DNA Health”

I am working on this problem: https://www.hackerrank.com/challenges/determining-dna-health/problem passing some test cases and time-out on others (no wrong answers). The code is here: ...
3
votes
2answers
138 views

Jump Game - Leetcode

Below is my solution for the LeetCode Jump Game Given an array of non-negative integers, you are initially positioned at the first index of the array. Each element in the array represents ...
3
votes
2answers
58 views

Finding paths between triangles efficiently in 3D geometry #2

This post is an update of the one from here. I've updated the code and a couple pieces of the post itself. I've been writing some functions used to find paths between two types of triangles - alphas ...
0
votes
0answers
25 views

First project using SCSS - A brochure website for a restaurant

I recently completed my first website using SCSS and thoroughly enjoyed using it over plain old CSS even though I didn't get use any of the advanced features of SCSS. I figured before I delve into ...
0
votes
2answers
94 views

Descriptive quantity (one, two, many) from number [closed]

I just write a simple method which returns a string based on the number in accepts as a parameter. I used if/elif/esle here but I think for this simple scenario I ...
2
votes
2answers
132 views

Run length encoding in C#

This is the original question: https://www.geeksforgeeks.org/run-length-encoding/ Given an input string, write a function that returns the Run Length Encoded string for the input string. For ...
3
votes
3answers
109 views

Finding paths between triangles efficiently in 3D geometry

An update to this post can be found here I've been writing some functions used to find paths between two types of triangles - alphas and betas. Alphas are triangles that have been in a zone we ...
2
votes
2answers
91 views

Check whether a string has all unique characters (time efficiency)

I don't find this algorithm in Go language here, so I just want to check that it is really most efficient algorithm in Go: ...
3
votes
2answers
28 views

git Create Tree from Arbitrary Directory (works in bare repository)

I made a script for a project I'm working on to create a tree object from a filesystem directory, without any working tree operations (can be run in a bare repository). The tree can be inserted into (...
1
vote
0answers
29 views

Stored procs fine tuning for processing bulk data - 5 million records

I have this procedure which is used for bulk upload data from a temporary table (temp_rules_master) into two other related tables. It has 5 million records. The ...
2
votes
1answer
56 views

Loop to copy values from one sheet and paste the values 68 times in another, time efficiency

I have created a large VBA program to automate creation of a data table that is needed to run slicers in an Excel file. While the loop works well in creating what I need, the main loop take an hour to ...
4
votes
1answer
60 views

Comparing objects in a list against each other

I have a list of ~27000 objects. Each object represents a line from a file where each line is one record of a measurement from some instrument. The most import aspects of the object are: Instrument ...
3
votes
1answer
56 views

Calculating all flight connections

I am working on an API to return all the possible flight route between point A and B. I have a set of data which includes the flight number, airline, departure airport, destination airport, ...
1
vote
0answers
20 views

Merging partial objects while avoiding path collisions and ordering array indexes

I have been creating a small library to copy parts of deeply nested objects through path strings that supports wildcards. For that I list all paths and values actually found as ...
0
votes
1answer
19 views

Querying nearest city with a given shop using latitude and longitude is slow

I am using the following query to search for the nearest city to my location from the cities table using latitude and longitude. The query also checks whether the nearest cities to my location have ...
17
votes
5answers
4k views

Speeding up thousands of string parses

I have a mapping application which takes string arguments in the form of string arrays. I parse these and then perform an action on the map. One of these is ...
2
votes
3answers
78 views

Faster output to Sheet from a collection of Dictionaries

My code is currently offloading parsed data into multiple spreadsheets, but it's pretty slow: about 110k rows and 35 columns in 3.5 minutes. I was wondering if there were a more efficient way of ...