Questions tagged [efficiency]
Use this tag in reference to comparing the efficiency of various systems or algorithms, or methods to measure efficiency. Big O notation is more related to complexity, but could affect efficiency.
183 questions
-2
votes
2
answers
101
views
Algorithm to utilize subsets of cache [closed]
We are using an external library for caching. How it implements caching is by creating a hash of all the arguments passed to the function and uses the hash as filename of the cached file. The result ...
1
vote
2
answers
426
views
Most efficient mapping of pixel to colors with colormaps
I'm working on a module that handles colormaps and I want to make the mapping of pixel to colors as efficient as possible. It is a performance critical section of our app. Our current solution works ...
24
votes
6
answers
8k
views
Best practice for redundant conditions in if-elif-else statements
What is considered better practice?
Case 1:
if n == 0:
doThis()
elif n < 0:
doThat()
elif n > 0:
doSomethingElse()
Case 2:
if n == 0:
doThis()
elif n < 0:
doThat()
else:
...
0
votes
4
answers
359
views
Do blockchains provide any improvement over conventional systems/frameworks when decentralization is not required?
I generally understand the blockchain framework. I have spent much time learning about how it, potentially alone, is able to provide for a decentralized system. For TRUE/ABSOLUTE decentralization, it ...
1
vote
0
answers
126
views
Is there an optimal strategy for placing rectangles inside a window without overlapping?
My specific problem is that I have a vertically scrollable window into which I need to place rectangular <div> elements that are locked horizontally and have different widths and heights. ...
0
votes
1
answer
270
views
How is it possible to have an efficient edit-compile-try cycle on large codebases?
Related (but different) question:
How do you dive into large code bases?
I have always worked on small projects where editing a piece of code is easy: you modify the code, you recompile and in a ...
3
votes
7
answers
5k
views
Representing a large list of complex objects in JSON
I am currently developing an API that returns JSON structures. One of the domain objects returned is a time series, which is a potentially large list (many thousands of elements) of complex objects.
...
-1
votes
1
answer
78
views
In a language interpreted line by line - is optimizing similar lines of code within a module into functions better in terms of efficiency? [duplicate]
While writing python code (I write python-selenium for GUI automation), I am facing situations wheer I have to deal with 5 widgets that do the same thing, just there xpath is differs by one term.
# ...
0
votes
3
answers
4k
views
Is it any more efficient to reuse a variable than to create a new object?
In a project I am working on we load various entities from the database, do some work then attempt to save the resulting entities.
If saving the result is not successful, we return a Result object ...
-1
votes
3
answers
1k
views
Does wrapping functions/'things' in classes reduce efficiency?
I was reading some C++ object-oriented programming notes that mentioned that we should avoid wrapping functions in classes if it is not required, since wrapping 'things' in classes would reduce ...
33
votes
4
answers
7k
views
I am spending more time installing software than coding. Why?
I am developing code mainly using Bash, C, Python and Fortran and recently also HTML/CSS+JavaScript. My OS is Ubuntu.
Maybe I am exaggerating, but I figured that I kind of spend more time getting ...
7
votes
12
answers
4k
views
Why do or should programmers save data in text based formats like JSON or XML instead of binary?
I see a lot of reasons to use binary over text-based formats.
With binary, I find it a lot easier. I can use fread(data, sizeof(struct DataStruct), 1, fileptr) to read, or fwrite to write data. I ...
2
votes
2
answers
115
views
How can I efficiently make changes to a large module without having to re-run every time?
When making changes to larger modules in Python, this is my current (inefficient) process:
Make needed change to code
Run program to test (using pdb - python3 -m pdb path/to/script.py
Program will ...
3
votes
3
answers
204
views
In which order perform tasks from big backlog
I have a big backlog of tasks gathered during last years. And new tasks are added occasionally. All tasks have the same priority and tasks never expire over time.
I was thinking of the reasonable way ...
1
vote
1
answer
754
views
Write complex query OR write simpler queries and combine the results in Backend service?
Take the following statement for example:
'Get results for ALL Active students of a Course'.
Naturally, this query has 2 parts,
Get all active students of the course.
Get results of those ...
3
votes
2
answers
369
views
Most efficient way to return results to a web page with a sorting algorithm
Recently, I've been building a search page where the user can input their search criteria and the server side will use a scoring and sorting algorithm to return the 'best' results first. The current ...
0
votes
2
answers
631
views
Ordered data structure with efficient push, iteration and random pop/drain
I need a data structure d with somewhat conflicting requirements. What are the different tradeoffs I could pick?
The same algorithm will be repeatedly done on each time step:
push one new element to ...
5
votes
4
answers
2k
views
When building time takes so long, how to improve engineer's efficiency?
The project is using C++ and the code takes around half an hour to build on a 32 core box. That time can be longer, e.g. 1 hour+ on a developer's local machine.
I notice the efficiency is low when ...
-4
votes
1
answer
113
views
Multi-level random selection implementation [closed]
Structure
I have a structure like this:
level 1 items represented by a capital letter (A, B, C, D,...)
level 2 items represented by lower case letter (a, b, c, d,...)
level 3 items repredented ...
0
votes
0
answers
27
views
Efficiently querying for a set of objects for price comparison
I am designing a system where a user can input a budget and a query returns to them sets of objects that they can afford from different vendors. The system has 100s of different combination types (i.e ...
1
vote
3
answers
3k
views
What is difference between assigning to auto-Implemented properties VS their backing fields within the class
Before I started using auto-implemented properties, I was taught that when assigning properties in the constructor (because of the potential of making a property read only), I should assign directly ...
3
votes
1
answer
236
views
Reducing Redundant Calculations
I am experiencing a dilemma. Let me explain it with two functions:
# Takes vector.magnitude(), vector.x, vector.y and uses it somewhere
def func1(vector, {other parameters 1}):
pass
# Takes ...
0
votes
3
answers
2k
views
Global state variables vs constructor parameter passing
A couple of readonly variables will be used. Almost all of the classes will be using those variables. Either I place all of the variables in a separate internal static class or I pass them on ...
0
votes
1
answer
4k
views
Does it make sense to iterate a ranged for loop using constant reference here?
I have the following code, and I was wondering if I'm optimally iterating through my ranged for loop:
struct data_type
{
int a;
int b;
};
int main()
{
// Assume I have initialized a ...
0
votes
1
answer
764
views
Is my reasoning to determine this algorithm's Big-O correct?
Take the following algorithm with two separate sections, and the sections do not influence each other whatsoever (the function is not recursive, as well).
void algorithm(int x)
{
// This section ...
6
votes
1
answer
1k
views
Fastest way to find N closest vectors to vector X in list?
I have a bunch (~20,000) of large (~200 dimensions) vectors in an unsorted list. I can create a new vector of the same size, and I'd like to find the top N (usually 10 or so) closest (defined by ...
2
votes
4
answers
4k
views
Avoiding if statements in Nested FOR loops
Please pardon me if this is a duplicate question.
I have two nested for loops which will iteration for around mn times (the complexity is around 3k).
Inside these for loops, I have 3 If conditions ...
6
votes
3
answers
4k
views
Effecient algorithm for data deduplication in procedural code
I have written a data cleansing application which, for the most part, works well. It is not designed to handle large volumes of data: nothing more than about half a million rows. So early on in the ...
0
votes
1
answer
168
views
Algorithm to identify differences between two sorted data sets
PROBLEM STATEMENT: Print the items that differ between the following two left and right sorted data sets:
A A
B C
C D
D E
G F
H EOF
EOF
The proposed solution ...
3
votes
1
answer
838
views
Why are (hexadecimal) hashed passwords/cookies/.. saved as strings in databases?
I'm wondering why all databases seem to store hashed passwords and typical hexadecimal data as char(x)/varchar(x)
MySQL uses latin1_swedish_ci as default character encoding, where each character is ...
0
votes
2
answers
104
views
Efficiently computing and storing global state
I am working on a graph problem which is special in the sense that the nodes are computed only when required. This is because the graph is so huge that the entire graph won't fit in memory.
So, in my ...
83
votes
7
answers
17k
views
Why are bit masks called "masks" and what purpose do they serve?
Why are "bit masks" called like this?
I know that they are mainly used for bitwise operations and the usage of bit masks is more efficient than the usage of separate variables.
However my question ...
5
votes
2
answers
640
views
Why don't all languages have the same efficiency?
I just finished my compilers course. One of the topics discussed was ways to make compilers more efficient. For example: tail recursion, inlining procedures, strength reduction, removing dead code, ...
-4
votes
1
answer
57
views
Technique to master new (third party) projects [duplicate]
I'm a graduated software developer.
In the last year I worked like a sysadmin, nowadays, I entered on a different software company as a VB.Net Developer, it means I need to learn and master a very, ...
2
votes
1
answer
2k
views
Are some operation system (kernels) more efficient with hardware than others?
When comparing the Windows, macOS, and Linux kernel to each other, do some make better use of hardware in terms of cache efficiently, page lookups, or power consumption?
I noticed this after ...
0
votes
1
answer
90
views
Where to format number strings? Server or browser?
I am storing numbers in my database without formatting (e.g., 1434587). But I need a formatted string in the UX (e.g., $1,434,587).
Is it better to store the raw number AND the formatted value in the ...
-1
votes
2
answers
8k
views
Fast and simple hex compression
I'm working on a project that requires a TCP connection between a client and server. The current protocol encodes the data into hex and then sends it. However, hex increases the length of the payload ...
0
votes
4
answers
345
views
Avoiding All Nighter Situations in Software Development [closed]
Trying to understand how experienced programmers tackle programming when they are stuck with a really hairy issues.
The situation that I face a few times is like I am stuck with code for quite a few ...
2
votes
7
answers
1k
views
Do we really need efficient algorithms? [duplicate]
I'd like to ask why people devote their time to research algorithms and their efficiency so extensively when computers nowadays are so fast.
Trying to come up with an answer I thought that maybe my ...
-1
votes
2
answers
204
views
better way to load data for millions of users
I am working on a Spring/JSF app in which i have 1 scheduler to load user's sleep activity from fitbit. Right now what i do is that whenever the scheduler kicks in, I load ALL users from mongoDB and ...
-2
votes
2
answers
146
views
Is using AJAX worth it in the inner administrative system? [closed]
Imagine we have a administrative system that is designed to be as fast and lean as possible, without too much fancy CSS or JS. The UE is not that great, but still it is pleasing on the eyes and gets ...
1
vote
1
answer
663
views
Should I use this very short Python Quicksort implementation?
def quicksort(N):
if len(N) < 2:
return N
else:
less = quicksort([number for number in N[1:] if number < N[0]])
more = quicksort([number for number in N[1:] if ...
4
votes
3
answers
14k
views
Most efficient method for large switch statements
Let's say you have many paths that an application can take at a certain point based on the value of a specific input (for example a simple int). Is there a certain method that is most efficient for ...
2
votes
1
answer
576
views
Creating a service to to run logic / queries and update a table vs. running logic / queries on client refreshes
I'm not sure if this is a thing. I'm sorry about the ambiguous title--I wasn't really sure how to explain it. Basically I have a ASP.NET web page that runs two SQL queries and does some logic to ...
6
votes
1
answer
375
views
How do I feel more productive after programming? [closed]
I really enjoy the actual programming part of programming, and actually writing the code, and figuring it out. But on this project I've been working on, most of my time has been spent on kind stupid ...
2
votes
2
answers
7k
views
What is Big O of sqrt(1) + sqrt(2) + ... + sqrt(n)? [duplicate]
Given for example this code:
for(int i=1;i<n;i++)
for(int j=1; j < sqrt(i); j++)
foo(); //foo takes constant time
can someone explain to me how to calculate the ...
-1
votes
3
answers
364
views
Is there any technical reason to be concerned with casting speed?
So, I'm working on a project that takes a very complex entity from a third party framework and converts it into the native object that defines that entity. This entity has several one-to-many ...
-2
votes
2
answers
3k
views
Most efficient way to find top values
Let's say we're given n positive integers in random order. What's the most efficient way to find the m largest elements and what's the complexity?
For example, given 1000 values, find the top 10.
0
votes
3
answers
131
views
Getting RowCount without wasting resources
I have a large SQL query that relates 6-7 different tables and returns fourteen different rows as distinct sets, in a union with an equally-large query, that at times can return over a thousand ...
1
vote
2
answers
2k
views
Efficient Repeating Alarm Clock in Low Level Language like C
I was thinking about it and I was curious as to how one would code an efficient repeating alarm clock in C? Would you set an alarm time and then offset the time with the ms time equivalent of a day (...