Skip to main content

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
4 answers
592 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 ....
Martin Frøhlich's user avatar
8 votes
4 answers
7k 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 ...
DJMcMayhem's user avatar
-1 votes
2 answers
5k 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 ...
Flame_Phoenix's user avatar
1 vote
3 answers
231 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 ...
ridthyself's user avatar
2 votes
1 answer
266 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 ...
dtech's user avatar
  • 733
3 votes
3 answers
1k 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 ...
jhschwartz's user avatar
6 votes
2 answers
5k 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, ...
Ben Schwabe's user avatar
0 votes
3 answers
210 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 ...
Elias Pinheiro's user avatar
0 votes
3 answers
257 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 ...
victoroux's user avatar
  • 103
1 vote
5 answers
2k 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 ...
pacholik's user avatar
  • 145
69 votes
4 answers
40k 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 ...
Dennis's user avatar
  • 8,257
4 votes
6 answers
350 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 ...
dtech's user avatar
  • 733
1 vote
2 answers
209 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 ...
Rui Pedro Caldeira's user avatar
3 votes
2 answers
307 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, ...
sk29910's user avatar
  • 133
1 vote
1 answer
125 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 ...
David's user avatar
  • 255
0 votes
2 answers
174 views

Are case-studies an effective way of getting efficiency-focused team members to be willing to trade some efficiency for quality? [closed]

Firstly, this does not suggest that efficiency and quality are in conflict... only that some methods prioritize them differently. Secondly, this is not a question of whether you agree with Scrum ...
David's user avatar
  • 255
3 votes
2 answers
3k views

How do I make this functional DSL written in an imperative language more efficient?

Suppose I create a simple functional Domain-specific language (DSL) using an imperative language, in this case C++. Here is a simple implementation of a DSL that can has the notion of a simple value ...
quant's user avatar
  • 1,316
1 vote
1 answer
246 views

Optimizing and caching frequently accessed but rarely updated Tables

My app has some tables that will be rarely updated, probably just once in the beginning and at the system setup. Despite that, they will be frequently accessed. Almost every operation depends on ...
Akbari's user avatar
  • 169
5 votes
2 answers
7k views

How to avoid calling String.Replace() in a loop?

I am building a very simple email templating system in C#, and it works amazingly, but I have a personal issue with the way I designed it: Template looks like this: Hello {UserName}, Welcome to .... ...
Alexus's user avatar
  • 2,398
1 vote
1 answer
80 views

Need semi-efficient algorithm for 3-dimensional increasing sequence

I have a set of puzzle challenges for a prototype jigsaw puzzle kit, similar to commercial products offered by Thinkfun and Popular Playthings. I have a candidate list of 300 puzzle challenges and ...
onigame's user avatar
  • 149
0 votes
0 answers
150 views

Handling image and audio files in iOS

Currently I have an iOS app that downloads image and audio files from a server, but each view controller downloads its own set of image and audio files (This is because each view controller needs a ...
flizana's user avatar
  • 143
4 votes
1 answer
5k views

How does modulus work?

I am not asking asking how the mathematical concept of modulus works, or how 20 % 3 == 2 I understand this fine. I'm more curious how the compiler/interpreter determines this. I can think of a very ...
DJMcMayhem's user avatar
4 votes
1 answer
1k views

Single import in a large file vs. multiple imports in smaller files. [Golang]

I'm sure the folks at Google worked long and hard to ensure the programmer wouldn't have to worry about details like this, but I'm curious. In Go if I have multiple files in the same package, but ...
Adam 's user avatar
  • 1,397
4 votes
6 answers
32k views

Fastest way to determine if a value is in a list?

I'm aware there may not be a good solution to this problem. I'm looking for a fast algorithm that determines whether or not a value (let's say an integer) exists in a set of values, however I need the ...
sydan's user avatar
  • 373
4 votes
0 answers
113 views

IRLBot Paper DRUM Implementation - Why keep key, value and auxiliary buckets separate?

Repost from here as I think it may be more suited to this exchange. I'm trying to implement DRUM (Disk Repository with Update Management) as per the IRLBot paper (relevant pages start at 4) but as ...
Isaac's user avatar
  • 183
1 vote
1 answer
2k views

How would a compiler turn an else-if cascade into a switch?

I don't like switch in C and its descendants. Maybe it's the need for a break or the clumsiness of the syntax requiring a shifting of mental gears, I don't know. Whatever the reason, I will almost ...
billpg's user avatar
  • 611
0 votes
2 answers
235 views

What is better for scalability for this specific dataset, MongoDB or MySQL?

I have a web app which has users, forms, and volunteers signed up on those forms. Currently I am using MongoDB and have it setup with a collection for admins, and a collection for forms with ...
David Crosby's user avatar
0 votes
1 answer
10k views

Most efficient LINQ result for Contains() query

I currently use the following: var result = list.Union(otherList).SelectMany(l => l.children).ToList() foreach(var child in lotsOfChildren){ something = result.Contains(child) } I only use ...
Chris's user avatar
  • 196
2 votes
1 answer
57 views

Comparing path strings against list of rules

I am trying to find a way to enhance a filtering algorithm. I am developing a backup software that enables users to specify custom filters to exclude unwanted files/directories. Currently when trying ...
Zaid Amir's user avatar
3 votes
2 answers
7k views

Which way is more efficient for getting the space count?

I have just started reading Cracking the Coding Interview. One of the problems (specifically 1.4) after solving and then looking at the answer made me question the way it is done and decided to post ...
SurrealSyntax's user avatar
2 votes
1 answer
103 views

timed events to modulation of real-time audio

I am new very to audio programming and am having trouble figuring out the right kind of algorithm for converting control events (e.g. like MIDI) to real-time sound genesis with a buffer. At the ...
James Alvarez's user avatar
0 votes
1 answer
405 views

Efficient way to map changes in a filesystem hierarchy

I'm currently working on a project that will enable file searching based on metadata found in the file. It'll be comprised of 2 parts: a filesystem crawler that passively scans for changes and ...
Evan Plaice's user avatar
  • 5,795
9 votes
2 answers
16k views

What benefit is there to using recursive binary search over iterative binary search or vice versa?

In a recent assignment for my programming 2 class we tested the efficiency of searches by populating a java ArrayList with 13,040 strings. The sequential search was obviously slower than the binary ...
Jaken's user avatar
  • 223
1 vote
1 answer
278 views

Closest Point to Moving Target

I have a target which is constantly moving, and only its current position is ever known. I also have about one hundred objects surrounding it, and for each of these only the current position is known....
Evorlor's user avatar
  • 1,553
5 votes
4 answers
2k views

Why are return values from compare functions in many languages defined loosely?

Many languages define that compare functions should return ANY negative value, zero, or ANY positive value. Is there some reason that it shouldn't be clearly defined as -1 0 and 1? Does a wide range ...
Shane's user avatar
  • 163
1 vote
2 answers
4k views

When trying to find out if a number is even or odd: AND 1 or OR 0

I recently learned of the trick for finding out if a binary number is odd or even. If the last bit in the number is 0, then the number is even. If it ends in a 1, then the number is odd. In the ...
SirPython's user avatar
  • 139
6 votes
2 answers
1k views

Bottleneck performance in ECS

I've been looking into building an entity-component-system. Basically, an entity is just an id wrapped around a struct, components are data belonging to that entity(and reference said id), and systems ...
Daniel Martin's user avatar
6 votes
1 answer
4k views

(jQuery) What is wrong with methods such as .append?

tl;dr: What is wrong with the efficiency of methods such as .append() and what can be alternatives to this? Explanation: Hello everyone. I occasionally have to build A/B tests for websites, which ...
Davy's user avatar
  • 169
2 votes
2 answers
2k views

How does Yahoo's Smush.It work and why doesn't everyone use it?

I've recently come across an application by Yahoo called SmushIt. Apparently it does lossless compression on images. Sometimes the image size is reduced by as much as 90%. This of course has major ...
Alternatex's user avatar
  • 1,031
27 votes
1 answer
72k views

Efficiency of C# dictionaries

C# dictionaries are a simple way to find if something exists etc etc. I have a question though on how they work. Let's say instead of a dictionary I use an ArrayList. Instead of using ContainsKey (or ...
John Demetriou's user avatar
1 vote
1 answer
161 views

Should I do a different SQL table for user privacy settings or just keep it at the users table?

So I am developing a Web Application and I have some concerns about the database. I use a lot of boolean settings at the user table with the form privacy_allow_1, privacy_allow_that, ...
skoumas's user avatar
  • 13
4 votes
2 answers
1k views

How do I efficiently send notifications for different events to different users based on their preferences?

I'm creating a notification system for particular events. A user can set the criteria that match particular events (ie. New item, changed item, closed item etc) Items have different characteristics (...
Tom K's user avatar
  • 61
0 votes
3 answers
8k views

Using action array vs Switch Case [closed]

I have an occasion of code in which I will draw a different set of buttons in a screen (depending on the number of the buttons). One thought (and my current implementation) is to use an action array ...
John Demetriou's user avatar
1 vote
3 answers
4k views

What is more efficient, a single square root or multiple divisions?

Say I make a program that calculates all possible (integral) factors of a certain number that has been input. Is it theoretically more efficient to check with all integers up to the square root of ...
Tejas Ramdas's user avatar
1 vote
1 answer
366 views

How to approach program design with respect to data strucutres and algorimths - is there an equivelant of the OO design process for d.s.'s + algs? [closed]

My applogies for probably the worst written body of text I have produced in my life and many thanks to those willing to plough through it all. I was (and still am) not able to clearly express what I ...
man of's user avatar
  • 19
0 votes
2 answers
197 views

Should you avoid adding unecessary stack frames?

I have been working with laravel (PHP) recently, and there is an option when using their fluent ORM to define where clauses using closures. This gives us two, functionally equivalent, ways to specify ...
Benubird's user avatar
  • 218
29 votes
11 answers
11k views

When I test out the difference in time between shifting and multiplying in C, there is no difference. Why?

I have been taught that shifting in binary is much more efficient than multiplying by 2^k. So I wanted to experiment, and I used the following code to test this out: #include <time.h> #include &...
NicholasFolk's user avatar
5 votes
2 answers
505 views

Trivially Sortable Encoding for Arbitrary-Precision Decimals

I'm looking for a reasonably(*) space-efficient way to encode arbitrary-precision decimals (e.g. BigDecimal), such that when sorting the bit-pattern of the encodings lexicographically, the numbers ...
Dexter's user avatar
  • 293
1 vote
1 answer
112 views

Custom Domain or Attribute Reference Table or Both?

I'm designing my first real database and I'm weighing the pros and cons of how to enforce uniformity in my data. My first option is to create a custom domain and program my UI to only allow certain ...
Jonathon Anderson's user avatar
3 votes
5 answers
690 views

Simplicity-efficiency tradeoff

The CTO called to inform me of a new project and in the process told me that my code is weird. He explained that my colleagues find it difficult to understand due to the overly complex, often new ...
Tawfik Khalifeh's user avatar