Stack Exchange Network

Stack Exchange network consists of 174 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.

10
votes
3answers
567 views

Implementation of Luhn credit card algorithm

I've implemented Luhn's algorithm for checking credit card numbers. My code works, but I wanted to learn about a more efficient and more Pythonic way of doing this. ...
-4
votes
0answers
21 views

How do you properly organize data to compute multiple (independent) recursive filters at the same time taking advantage of SIMD instructions? [on hold]

I'm processing multiple (independent) Exponential Moving Average 1-Pole filters on different parameters I have within my Audio application, with the intent of smooth each param value at audio rate: <...
2
votes
2answers
68 views

A recursive algorithm to find the number of distinct quantities of money from a pile of coins

Problem: find the number of distinct quantities of money that a pile of coins can make. The vector coins contains the values of the coins, and the corresponding ...
2
votes
0answers
42 views

Data Transfer Task

The task: You will be given several lines of messages containing data. You have to check for the validity of the lines. A valid line should be in the format: ...
1
vote
2answers
69 views

Functions to handle big numbers in C

I'm working to implement some simple bigint functions for addition, multiplication and powers. They work correctly but the larger the numbers the longer the time it takes. For example 2^10000 takes a ...
0
votes
0answers
24 views

Secret Santa : pick a pair [on hold]

I recently had to write some code to create a "Christmas Angel" list shuffler. Everyone in my school will have a secret person who makes little gifts, and will make gifts to another one. There is ...
0
votes
1answer
31 views

Monte Carlo Simulation [on hold]

Problem I need to estimate the volume of a given object using Monte Carlo Integration. I need to perform multiple runs in order to insure a given confidence of four digit. I am simulating integrating ...
3
votes
1answer
68 views

Hackerrank “Almost Equal” solution

I've spent the best part of a day on this question. It is marked as Expert level. There are about fifteen submission test cases and my solution manages to satisfy the first four. However, from there ...
3
votes
0answers
30 views

Distance transform on image using NumPy

I would like to find the find the distance transform of a binary image in the fastest way possible without using the scipy function distance_transform_edt(). The ...
-2
votes
0answers
14 views

Getting a Segmentation Fault after one iteration of the loop for text-based bluff(cheat) card game [on hold]

Please look into the following code for a text-based bluff(cheat)game. it should display the cards in hand for each user before their turn. ask for the cards they want to call, and then for the actual ...
1
vote
0answers
12 views

Iterate between dates and INSERT values in a performant way

I have created a query that populates a datapoint with random values. The logic is simple: Iterate between the START and END dates and INSERT random values. I want from this query to be very ...
0
votes
1answer
18 views

Java splitting too large text file enhance performance

I have a too large data.txt file containing data as follows: ...
3
votes
1answer
92 views

C++ Battleship player AI

Found this project online and looking for some guidance. I'm in the process of developing a Battleship AI that will play against different computer difficulties. The "barebones" part of the project ...
3
votes
5answers
669 views

Project Euler 92: count sum-squared-digits chains that reach 89

A number chain is created by continuously adding the square of the digits in a number to form a new number until it has been seen before. For example: 44 → 32 → 13 → 10 → 1 → 1 85 → 89 →...
2
votes
0answers
29 views

Implementing key map with expire and size limit

Recently I have been asked to implement a key map with expire time for each key and possibility to limit the number of keys, in Python. I've used a dictionary + heap to store the entries, e.g.: ...
2
votes
1answer
70 views

Speed up Magic square program

I have written a Java program to calculate magic squares with recursion and backtracking. A 3*3 Magic square is calculated in about 1 sec, but a 4*4 needs about 50 minutes on my laptop with Intel i5. ...
3
votes
2answers
40 views

Python 3 multi-threaded pinger

My goal: I want to ping every single IPv4 address and record whether or not they responded. The way I have it set up is every IP address corresponds to an index. For example ...
3
votes
1answer
36 views

Superscript all numeric characters after ^ in an excel cell

I have material property entries in a cell those look something like this: cell.value="O2 Permeability [cm^3/m^2]" The goal ...
3
votes
4answers
97 views

Count combinations of positive and negative that sum to target number

The problem I'm solving is given as follows: You are given a list of non-negative integers, a1, a2, ..., an, and a target, S. Now you have 2 symbols + and <...
2
votes
0answers
46 views

Historical exchange rate between currencies using Ecbxrate

I tried writing a simple python script using the python module ecbxrate that outputs to a CSV file a table with the daily exchange rate between EUR and USD since ...
2
votes
2answers
55 views

Project Euler #10 (sum of primes less than two million) in Clojure

I'm new to Clojure and using some Project Euler problems to familiarize myself with the language's capabilities. Problem #10 asks to find the sum of all primes less than two million. I wanted to ...
0
votes
2answers
50 views

Unbalanced Binary Search Tree insertion and search with random and sorted values

I have created this unbalanced binary search tree in C. Can anyone say this is a true approach or not? I have two scenarios for insertion and search: in the first scenario I am inserting 10000 random ...
0
votes
0answers
10 views

Building a system of ODEs, efficiently updating parameters and evaluating vecors of ODEs

I am building quite large systems of ODEs programmatically. I intend to find the steady states of ODEs under different parameter values. A boiled down example of my code is shown below. Comments with <...
7
votes
4answers
2k views

Most efficient way to find an entry in a C++ vector

I'm trying to construct an output table containing 80 rows of table status, that could be EMPTY or USED as below ...
0
votes
2answers
42 views

Count power of big numbers and then apply modulo on this numbers

I have this example code in which I have very big numbers as you see. Problem is that when I use this algorithm for some small numbers, it works well, but when I use it for big numbers like in this ...
1
vote
0answers
37 views

Optimising fingerprint scan compare process

I'm creating some python script in Raspberry Pi to running fingerprint scan and compare it against database. Using this library, on raspberry start this script will get all the database record for ...
3
votes
1answer
73 views

C# screen recorder [closed]

After a while of working on it, I've finally got my screen recorder to work in C#. I'm looking for suggestions to improve the video quality as well as clean up the code a bit. Specifically I want to ...
2
votes
0answers
23 views

Calculate average round cell value from each 2D array cell

I am try to practice the leetcode and hit the following question 'image smooth'. Basically the question is to calculate average the around cell value from a 2D array. I have following code. But if ...
1
vote
1answer
59 views

Addition function for two Big Integers represented as std::string

This function is from my attempt to write a Big Integer class in C++. Below, I have a simple addition function. It takes two strings of arbitrary length which contains only digits (no '-' sign as ...
1
vote
1answer
64 views

My Python 3.6 script to detect stamp card redeem fraud and prepare a csv report

I have a requirement to write a Python 3.6 script which should be able to detect following case within a time period and be able to create a text file report that lists the condition violated and ...
1
vote
0answers
25 views

Getting Video file path from uri

I am using below code to get a video file path from uri. Need review for the following: 1.Code optimization 2.Crash(Code is working fine in the devices I tested but i need to make sure that it ...
0
votes
0answers
26 views

Basic image median filter

Recently I implemented the most basic moving window transform version of a median filter that I could (it was actually just to have a comparison for another method, so I wasn't trying to optimise it ...
4
votes
2answers
70 views

Count characters in a string

This code is supposed to count each character in a given string and account for error handling and type casting as well, and it should do it in the most efficient manner possible, with O(n) being an ...
6
votes
1answer
1k views

Advent of Code 2018 day 1 part 2: find the first repeated number after some increases and decreases

Here is the problem: Part Two You notice that the device repeats the same frequency change list over and over. To calibrate the device, you need to find the first frequency it reaches twice. ...
2
votes
0answers
54 views

PHP + PDO - Inserting data on the table with a loop

First of all i made a simple code to insert data on my table, with the information from this code i made a loop to insert data on another table for a notification system. I'm new to PHP and i think ...
1
vote
1answer
55 views

Get maximum sequence lengths taking into account the tradeoff of omitted observations

From a data frame d I have to select the longest possible sequences of x. variables. Example: ...
3
votes
1answer
72 views

List of word to list of index in a vocabulary [closed]

I have a dataset composed of ~700k samples. Each sample is composed of n_features features. Each feature is a word. Each feature has his own vocabulary. The size of the vocabularies range from 18 to ...
5
votes
1answer
97 views

Requesting 400 links with multithreading and ThreadPool

I am working on multi-threading application to learn multithreading better. My application has a queue with 400 unique links, 4 threads and each thread is pulling link from the queue and sending a Get ...
1
vote
2answers
35 views

Wireframe animation on canvas is slow

I'm recently working on a project that involves animation in the background. It works well on desktop but performance drops drastically on mobile. I'm using Paper.js to import a svg and animate it. ...
2
votes
1answer
16 views

Offset vs Cursor Pagination

I am trying to compare any performance gain(s) from moving a current offset-based pagination endpoint to a cursor based one. I have the following ruby code: ...
2
votes
0answers
38 views

Excel VBA animation runs slowly after editing worksheet

My VBA macro displays an animation based on a row-by-row time step simulation in the worksheet. The user enters the desired inputs and the worksheet calculates the evolution of the simulation in a ...
3
votes
2answers
77 views

Class to store and manipulate Cartesian coordinates and vectors

I have made a C++ class to manipulate 3D vectors in Cartesian coordinates. However, the performance of my class is much slower (about 2.5x) than simply using something like ...
0
votes
0answers
34 views

Find if characters in string are present in another string

I need to match if the characters in a string are present in a haystack with following conditions: If match string has repeated characters, haystack must contain multiple characters. In case of ...
2
votes
2answers
66 views

Given some integers, find triplets where the product of two numbers equals the third number

I am trying to solve a coding challenge: Given N integers A1, A2, …, AN, count the number of triplets (x, y, z) (with 1 ≤ x < y < z ≤ N) such that at least one of the following is true: ...
2
votes
0answers
51 views

SIMD product of a 4×4 matrix and a vector

I wrote a matrix class for use in a ray tracer. I already have a 'scalar' version up and running, but now I'm trying to rewrite it to use Intel SIMD Instrinsics. I realize my compiler (clang-7.0.0) ...
0
votes
1answer
59 views

Parsing messages with fixed-width fields into Employee objects

I'm writing a application that reads from a queue of messages from a legacy mainframe system. Some characteristics of message in the queue: Message from the Q is always fixed length plain text : 64 ...
1
vote
0answers
16 views

Handling slow processing the Spring batch way

We are using spring-batch to extract data from a SAP system, during processing we pass the extracted full texts to a tagging service, in the end the enriched documents are stored in Solr to be served ...
5
votes
0answers
81 views

2-opt algorithm for the Traveling Salesman and/or SRO

In this question I present a method to solve the Traveling Salesman Problem and/or the Single Route Optimization problem. I am extracting 100 lat/long points from Google Maps and placing these into a ...
1
vote
1answer
36 views

Get the most frequent number and least frequent duplicate in array

This code gets the most frequent number and least duplicate number in an array. How can I optimize it and improve its performance? ...
2
votes
2answers
50 views

Checking hash and passwords with a wordlist, more efficient

I have done a small code in which with a wordlist (out68.lst) I get the passwords from the hashes in the file 'shadow3'. ...