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
1
vote
4answers
262 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 ...
0
votes
0answers
66 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
1answer
248 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 ...
2
votes
7answers
274 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
1answer
73 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
1answer
151 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
3answers
275 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 ...
32
votes
4answers
6k 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 ...
4
votes
12answers
1k 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
2answers
106 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
3answers
112 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
1answer
225 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
2answers
178 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
2answers
439 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
4answers
1k 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
105 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
22 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
2k 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
217 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
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
1answer
3k 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
358 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
1answer
966 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
2k 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
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
1answer
157 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
542 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
102 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 ...
82
votes
7answers
15k 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
2answers
591 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
54 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
81 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
2answers
5k 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
299 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
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
2answers
184 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
145 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
651 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 ...
3
votes
3answers
9k 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
562 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
350 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
4k 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
256 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
2answers
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
3answers
130 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
1k 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
438 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
5k 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 ...
-1
votes
2answers
4k 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 ...