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
0 votes
1 answer
8 views

Improving multiple FirstOrDefault statements on same collection

I'm having multiple FirstOrDefault() statements, in this case 2, on a collection. ...
1 vote
0 answers
26 views

Integration loop over multiple doping and temperature levels

I want to perform some calculations on a large dataset. The code can be found below, where I want to calculate the values for 'results_nr' over a large loop (1000 x 910) values. Can you help me out ...
3 votes
1 answer
145 views

Applying a cost function to a string based on a pattern string

I have a cost function Cost_Func(pt,STRING) that calculates value in a specific way based on the given pattern string pt and ...
3 votes
1 answer
44 views

Fast way to compute a^d mod n

For a Miller-Rabin primality test I need a fast way to compute a^d mod n. Where a is one of 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, ...
2 votes
1 answer
20 views

Matching corresponding masks of objects between 2 images

Here is a program that processes 2 grayscale images. Both represent the position of objects, in the form of multiple masks per image. Each mask is a shape with one color delimiting it, with 0 (or ...
0 votes
1 answer
65 views

Optimizing a program that checks through a very large set of permutations

I'm not sure if this is the correct place for an optimization question like this, but I'm not even sure where to start looking. So here it goes. There's this game I play that has very simple rules. ...
0 votes
1 answer
10 views

How to speed up truncating text to specific word count in nim?

I have a web application, as part of it I regularly have to send out "overviews" of records in a database, which contain shortened excerpts of a description-text of that record. What the ...
3 votes
1 answer
63 views

First assembly program: working with strings and integers

I started learning assembly some days ago and I wrote my first program today. Nothing exceptional here: some user inputs, strings manipulations, integer to string conversion etc... The only purpose ...
1 vote
1 answer
53 views

Minimum number of swaps to sort a array, but swaps only allowed with elements 2 apart

I wanted to solve a problem where I sort an array of any size and return the minimum number of swaps. The explanation for the distance 2 is that I choose 3 neighboring elements ABC and then swap them ...
0 votes
1 answer
25 views

Google App Script Automation for User Onboarding

Background I am a relatively new developer(> 2 years coding) working as an intern for a smaller company, as part of a now 4 person team. We had two other team members, one our system admin and the ...
5 votes
1 answer
160 views

Evaluating math terms as nested lambdas instead of expression tree

I need to store some math terms. Originally I would use a tree to do it, especially if parsing strings was involved. However, since the expressions are built within the code and need not be parsed, I ...
1 vote
3 answers
191 views

Find the 10001st prime number

Project Euler 7: What is the 10 001st prime number? I currently have this code: ...
1 vote
0 answers
57 views

Smallest interval whose sum exceeds a threshold

In a non-negative 1D array x, we wish to find the shortest slice such that x[start:end] > threshold, with constraint that <...
0 votes
3 answers
159 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....
1 vote
0 answers
16 views

Nodejs - Javascript buffer that takes in uint64, enum and string data as input

I am writing a nodejs program that adds some data into a buffer, before it is streamed. The data types are listed in the comments of the code, and there are fixed places in the buffer that these data-...
2 votes
1 answer
83 views

Snake from the viewpoint of the snake

I wrote a little game of snake that where you can see the field in which the snake moves fixed and you can also see the "viewpoint" of the snake, which is basically calculating the positions ...
2 votes
2 answers
67 views

Coordinate Descent Non-negative Least Squares optimization

In my fast implementation of Non-negative Matrix Factorization (Rcpp Machine Learning Library, RcppML), about 40% of the runtime is spent solving Non-negative Least Squares (NNLS) systems (the rest of ...
1 vote
2 answers
135 views

group countries by language in JavaScript

I need a better implementation than the below code (O(N) Solution), I am grouping countries by language ( data ) is the countries JSON, each country could have 0, 1 .. or more language as the object ...
2 votes
0 answers
46 views

Cosine similarity calculation in Rust, which is slower than NumPy

I'm running this in release mode. Currently, the following function takes around 6.7 seconds to run on my computer vs 3.7 seconds on Python. I know that Numpy is just calling to C, but I'm trying to ...
0 votes
0 answers
41 views

Web Scraping: finding a particular content and taking an action for multipule pages

Summary: the whole code is given at the bottom the problem (or say main concern) is described hereinbelow. The code scrappes the website goes through various pages and finds particular content to ...
1 vote
1 answer
1k views

Lo Shu Magic Square (Python)

I wrote a python program to find if a matrix is a magic square or not. It works, but I can't help feeling like I may have overcomplicated the solution. I have seen other implementations that were a ...
5 votes
4 answers
12k views

Preprocessing steps to follow while cleaning and extracting text data from tweets

I have a dataset of around 200,000 tweets. I am running a classification task on them. Dataset has two columns - class label and the tweet text. In the preprocessing step I am passing the dataset ...
0 votes
1 answer
48 views

Optimization using a differential evolution technique, ideally with a million iterations

I'm working on an optimization code using differential evolution to solve. However, it is taking a long time to get the solution. See that I have a variable called number_of_iterations that must equal ...
1 vote
0 answers
49 views

Rust code implementing cosine similarity

I've been trying to create a piece of code which consists of looping through each element of a list of questions, preprocess it, and then calculate the Cosine similarity with the rest of the elements (...
4 votes
1 answer
899 views

PowerShell - fast remove a directory with 10,000+ files

I am sick of File Explorer's super slow deletion speed, so I tried to write a PowerShell script to make deletion faster, and while it does its job, its speed isn't as high as what I intended it to be. ...
1 vote
1 answer
157 views

MATLAB / vs Python np.linalg.solve, heat diffusion

I am solving a simple 1D steady heat question using spectral method. I am a long time MATLAB and Mathematica user and trying to learn Python. I compare only linear solving times and Python is way ...
1 vote
3 answers
51 views

Removing medications older than 180 days ago from a list

I have the following code which removes a dict from a list of dicts in Python based on ...
0 votes
1 answer
42 views

Laravel 9 - Metadata creation using middleware?

I wrote a middleware for laravel that grabs the current metadata for the specific URL you visit. How it works: we use the $request and compare the current URL: <...
5 votes
1 answer
121 views

Check the stock of references list

I did this spider that checks the stock of references list (around 3500 references). Now the spider takes around 37 seconds to scrape 400 references. The CPU is around 5%, the network card (1Gbps) ...
8 votes
4 answers
4k 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 ...
0 votes
1 answer
36 views

Approximation of the multiplicative matrix inverse (linalg.inv ())

I am trying to compute the multiplicative inverse of a large matrix (~ >40,000x40,000). This can be done with e.g. numpy.linalg.inv or ...
-3 votes
1 answer
39 views

Printing contiguous sub-arrays

The following method of printing all subarrays(contiguous subsequences) of an array is faster as compared to the general method of using three nested for loops: ...
3 votes
1 answer
47 views

Weighted Union-Find class

For a final project I used a weighted union-find and decided to implement it in Python. I wrote it to be as general as possible so it's very portable. I do plan on looking into path compression to ...
5 votes
3 answers
855 views

Reducing the time for rolling hash

I tried this problem below and solved it in O(test_cases * string_length * pattern_length) complexity involving three nested loops. I want to know how can I further decrease time. I figured as much: 1:...
1 vote
1 answer
45 views

Cleaning up a PANDAS dataframe of Brazilian football statistics

I am trying to cleanup a dataframe (and the code) in Pandas. I used to use the modin library before but I have since switched from Win 10 to Win 11 and none of <...
0 votes
2 answers
101 views

Is this a good way to check for an anagram if sorting is not allowed?

So I decided to lookup some algorithms, and one of the ones I found was.. "Check if the string is an anagram" and without using Google for more than checking what an anagram is, I decided to ...
1 vote
1 answer
3k views

How can I make this SQL Bit scalar function more efficient?

I'd like to make this SQL scalar function more efficient. How can I do that? ...
2 votes
0 answers
108 views

Networking code for a Golang P2P library

I am working in a Noise-based P2P lib that has only basic TCP networking implemented so far. I am looking for anyone who get interested in this project that want to helps with reviews to the code and ...
2 votes
1 answer
42 views

CSS gradient text that fades in and out

Here I have a basic text gradient effect which fades into a gradient animation, and fades out of the animation on hover in/out. Without the fade in, it looks janky and jolty. But because of the fade-...
7 votes
4 answers
179 views

Sum and bubble-sort student scores

I am a beginner in C language. I studied all night and did my assignment. But I wonder if there is a more efficient way. The original structure is this. ...
4 votes
1 answer
99 views

Vectorset, a faster std::set

I decided to implement a vectorset, which is intended to be faster than std::set for the 3 fundamental operations, namely insert,...
0 votes
2 answers
97 views

Encryption and Decryption in C

I have written a program in C, which encrypts and decrypts a c-styled string (const char *) and print the result to stdout. It ...
1 vote
1 answer
57 views

Adding string to a text file without duplicates

I have a function below, store_in_matchid_file, and it adds certain strings to a .txt file as long as that string doesn't already exist in the file. However that ...
5 votes
1 answer
154 views

Filter Range VBA function for Excel

Premise I have written a function in VBA, called FILTER_RANGE(), which accepts a Range object and a filtration parameter. Unlike ...
1 vote
1 answer
49 views

Generate new column based on two columns of dataframe

I need to generate column a_b based on column a and column b of ...
5 votes
1 answer
279 views

Cracking a 4x hashed md5 with a couple of hints

I made this project in my free time to try to crack a 4x hashed md5 with a couple of hints but I'm looking for ways I can optimize this algo because it's pretty slow and I know you could probs use ...
0 votes
1 answer
45 views

Remove columns in HTML table where the sum is 0

I have an HTML table, and I would like to remove columns where the sum vertically is 0 dynamically. ...
4 votes
1 answer
157 views

Algorithm Optimization -- Automatic Dimensionality of PCA

I have implemented (rather, edited the implementation of) a technique to automatically detect the optimal number of dimensions for PCA, based off of this paper. This was inspired by ...
1 vote
1 answer
77 views

Python: Generate SHA3 hashes for files with custom rate and capacity values

I am working on a project which requires comparing the performance of SHA3 on different values of rate and capacity. I have implemented the same in Python and my program works fine, however, the ...
8 votes
2 answers
1k views

Measure the total runtime of a function in a project

I recently wanted to find out which functions take which amount of time in a project, and calling a timer and printing the difference inside a function that is called multiple times does not scale ...

1
2 3 4 5
171