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.

Filter by
Sorted by
Tagged with
0
votes
0answers
8 views

Rapid requests to REST or alternate solution

React Application on top of Flask Currently I am developing a REST API where users will submit tasks, these tasks will run for an indeterminate amount of time and it is quite literally impossible for ...
-2
votes
0answers
11 views

How to efficiently move the decimal point in a number until reaching some threshold [migrated]

Say I have a double x, whose value is > 0 and < 1 million. I want to move its decimal point left until it is > 1 million and < 10 million. So for example, 23.129385 becomes 2313938.5. What I'm ...
5
votes
4answers
400 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
1answer
87 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
0answers
20 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
3answers
190 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
1answer
203 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
3answers
768 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 ...
-1
votes
1answer
636 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
1answer
74 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 ...
5
votes
1answer
604 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
4answers
566 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
3answers
2k 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
1answer
114 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
1answer
247 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
2answers
94 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 ...
79
votes
7answers
14k 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 ...
4
votes
2answers
554 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
1answer
51 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
1answer
1k 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
1answer
71 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 ...
-2
votes
2answers
3k 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
4answers
242 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
7answers
757 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
2answers
179 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
2answers
144 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
1answer
566 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 ...
1
vote
3answers
4k 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
1answer
513 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
1answer
342 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
2answers
2k 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 ...
0
votes
3answers
250 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 ...
-1
votes
2answers
1k 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
3answers
128 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
2answers
892 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 (...
1
vote
4answers
353 views

Should I be using any algorithm to sort/find items, or use a language's built-in ways?

I'm currently a first semester IT student, and I'm wondering if it's better to write my method to find something e.g. in a C# List, or to use any built in method to do these, such as LINQ or .Find or ....
9
votes
4answers
3k views

What is the most efficient way to store this data?

I am in charge of rewriting some old VB code. I understand how it works, but I feel like there is a far-more efficient way to do what they did. I just can't figure out what it is. Here is a contrived ...
0
votes
2answers
2k views

How to scramble a word, keeping first and last characters the same?

I have a task, which is to scramble a single word, whose size is greater than 3 letters. The scrambled word must not be equal to the original, and the first and last letters of the word must remain ...
1
vote
3answers
126 views

Reading from Memory vs Performing an Operation [closed]

I'm learning to program microcontrollers and am trying to develop good habits: Suppose I have a set of values which can be calculated based on what is already in memory. As a general rule, is it ...
2
votes
1answer
230 views

Low cost exceptions implementation using metaprogramming [closed]

(preface - boring stuff, feel free to skip down to the implementation details) I need to provide exception handling to a language I am working on. It "compiles" to a subset of C, and since I don't ...
2
votes
3answers
612 views

Temporary Variables or Not: Choose CPU Time or RAM? [duplicate]

In a case where multiple variables are set equal to an operation using the result of an other operation, is it best to create a temporary variable for the result of the second operation (this would ...
5
votes
2answers
3k views

Sort a list while putting together or after?

I have to read through an extremely large amount of network data from various log files, and compile relevant information about that data to perform statistical analysis on it (the top communicators, ...
0
votes
3answers
202 views

Difference of efficiency [duplicate]

I'm doing a compiler, and I'm using the System.out.println(); to print assembly; And the code get bigger, and more complicate to understand. I want to know whats is the difference of efficiency ...
0
votes
3answers
212 views

Identical Databases for Multiple Users Reading Efficiency

Our project utilizes a static database (no writes). With many users we don't actually have a problem per se reading it. If a database "locks" per read request by any user, then would it not be more ...
0
votes
5answers
1k views

How do I avoid having to compute square roots for every element in a data set?

I have a list of points, with floating point coordinates, of which I've computed the square of the Euclidean distance between these points. I have not computed the actual Euclidean distance between ...
34
votes
2answers
12k views

Is it wasteful to create a new database table instead of using enum data type?

Suppose I have 4 types of services I offer (they are unlikely to change often): Testing Design Programming Other Suppose I have 60-80 of actual services that each fall into one of the above ...
4
votes
6answers
300 views

Class design, responsibility granulation, efficiency and performance

I am in a design dilemma. I have a set of data that can be interpreted in numerous ways, but I cannot really decide how finely grained should it be. To illustrate it with some simple code: class Base ...
1
vote
2answers
136 views

Multi-pattern matching

I have a given byte array in C and I need to match it against several byte arrays and return true if there is any match. I can make various memcmp's but I feel that it is very inefficient. Do you ...
3
votes
2answers
289 views

Reducing a sequence of array modification operations (insert, sort, replace, remove)

Given a plain array of values, e.g. ["Apple", "Orange", "Banana", "Strawberry"] and a list of operations from the set of [insert, delete, sort and replace], e.g. [ {cmd: "insert", index: 2, ...
1
vote
1answer
103 views

What is a good metric for guiding a switch from a prototyping language to a production language? [duplicate]

By "prototyping language", I mean one which was chosen by virtue of it's relative ease of quickly accomplishing the sort of design changes common to prototyping in a particular context. (such as data ...