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 [optimization]

Optimization is the process of improving an existing program to make it work more efficiently or/and using less resources.

0
votes
2answers
43 views

Problem in modelling this because too slow calculation (robot football)

I like to build a component connector view / UML diagram for the given problem but I realized it's way too slow if you try to do it exactly as it's given in the following text. My question is what ...
-2
votes
1answer
53 views

Method that takes array parameter [duplicate]

I want to implement two methods: AddPlayers and AddPlayer. Is it better when AddPlayers calls AddPlayer or AddPlayer calls AddPlayers with a single item array? Is there a significant difference in ...
5
votes
2answers
421 views

How can arithmetic, like a bit shift, avoid branching?

I'm learning to program the Game Boy Advanced (an old Nintendo console.) I was reading one of the best tutorials about it and it said this about how branching can be done with arithmetic. [To ...
1
vote
1answer
60 views

Create and implement new encoding

I'm working on a project with huge files that contain only the set {[0-9],.}. Encoding in UTF-8 or ASCII make huge files. I wonder if I could find a way to encode in only 4 bits (make those file 16 ...
-3
votes
2answers
171 views

C/C++ code optimization without compilation

Given a simple loop in C or C++ such as the following: for (int i=0, j=0; i<5; i=i*2){ j=j+i*1; } I would like to use a tool (gcc, clang or any other) to optimize the code without actually ...
3
votes
1answer
471 views

Why am I advised to not inline functions that are called only once?

I understand inlining as the following: A separate function which is marked as "inline" (assuming the compiler really does inline) will be "merged" into the function it is called. i.e. (pseudo code)...
1
vote
3answers
266 views

Do any compilers do this optimization for virtual calls?

This just came to mind, and not really sure how to search for this. Let's say you have the following classes class A { public: virtual Foo() = 0; virtual ManyFoo(int N) { for (...
1
vote
2answers
174 views

How to benchmark software performance under same conditions (RAM, CPU caching etc)?

I am writing a software that splits big files into smaller files and I have coded several solutions. I am measuring the execution time of each of my solutions. (with threads, go routines, MPI etc) ...
1
vote
6answers
214 views

Optimization of iterative loop with removed items

I am translating a piece of software from an old language to c++ and am currently in the optimization stage. The software performs a calculation of loads for several items in a number of timesteps, ...
10
votes
1answer
263 views

Redundant code sent down the pipe with Micro-frontends

My understanding of Micro-frontends is that the key problem they solve is in helping enterprises have multiple, possible disparate teams, work on individual components/small-apps that will be used to ...
0
votes
2answers
130 views

How to build reports for an ecommerce webapp without slowing it down

We have a medium sized ecommerce website which is entirely custom built in using Java and MySQL database on AWS infrastructure. Over a period of past several years, our orders volume has grown ...
0
votes
1answer
72 views

Should I print to the page from a javascript object, or only render from PHP?

I have a complex app on the Javascript/PHP/SQL stack which manages different domain objects. The Javascript layer contains classes which manage the data on the client side. I am currently baking a ...
2
votes
4answers
370 views

What is the optimal way to perform 5000 unique string replace functions in terms of performance?

Restructuring some code, and the way I built it up over time has portions that look something like this: s.replace("ABW"," Aruba "); s.replace("AFG"," Afghanistan "); s.replace("AGO"," Angola "); s....
25
votes
2answers
3k views

Implementation of pure abstract classes and interfaces

Although this isn't mandatory in the C++ standard, it seems the way GCC for example, implements parent classes, including pure abstract ones, is by including a pointer to the v-table for that abstract ...
1
vote
1answer
151 views

Most compact way to represent a graph [closed]

Given these nodes: a b c d e f g h And given some edges between the nodes like this: a/b/c b/c/d c/e c/d/e/f c/g f/g e/f/g a/c/h h/a/b c/a d/b/c f/g/c d/a/f g/f g/a/b/c f/a/b e/a/c (where a/b/c ...
2
votes
1answer
106 views

How to optimize a complex task with multiple DB calls

I have been working on a multi-layer, sale management application developed with WPF and partly refactored with EF6 (long story). The application has some very complex tasks which require multiple ...
9
votes
5answers
4k views

Is passing arguments as const references premature optimization?

"Premature optimization is the root of all evil" I think this we can all agree upon. And I try very hard to avoid doing that. But recently I have been wondering about the practice of passing ...
0
votes
3answers
362 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 ...
4
votes
3answers
307 views

Using of different language in same project

I was started programming in 6 months ago in college. I learned Python, C and Java. I want to create a project and using these languages. For example to searching part should use C because it's faster ...
2
votes
1answer
177 views

Whole-program optimization

I just asked about the Polyhedral Model, and have looked into other compiler optimizations (Loop unrolling, Constant folding and propagation, Dead code elimination etc.). But I haven't seen anything ...
0
votes
2answers
60 views

Ideal AB testing architecture to optimize for engagement

I'm pushing out a new feature soon that has a lot of different UX components. The key metric that I want to track is user engagement (I have the equation for what this means for me and how to measure ...
0
votes
0answers
29 views

GIS design for reducing of traffic and number of requests to server

I explore the world of GIS and try to elaborate an architecture of a GIS service with a lot of objects on a map. Currently, I'm loading all the items in the visible map area. In order to keep a map ...
4
votes
1answer
461 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 ...
4
votes
4answers
733 views

Rely on compiler to remove unused code or #ifdef out?

I am working on a USB stack in C. This stack will be open source and used in various different projects. Various configuration options are available, which enable or disable large chunks of code and ...
0
votes
1answer
492 views

MPA vs SPA for first-load performance & meta tags?

Let there be a static web application. Let the following be a priority: First loading time (ignore cache etc) User experience Search Engine Optimization (meta tags & bot friendliness) When ...
19
votes
10answers
1k views

When is it better to optimize a software for better performance, at the beginning or at the end of the development?

I'm a junior software developer and I was wondering when would be the best time to optimize a software for better performance (speed). Assuming the software is not extremely large and complex to ...
0
votes
0answers
124 views

Best approach to solve a problem with a lot of combinations (priorities/check if combination is valid)?

I'm currently working on a little problem (part of a bigger material flow control system) and wondering if my planned solution for one of the connection between two halls is good or there are clearly ...
1
vote
1answer
44 views

Efficiently broadcast user status

This turned out to be a rather interesting problem contrary to my expectations. Imagine a simple chat app, a user registers then can add other users to their contacts list and start conversations. I ...
0
votes
0answers
53 views

Efficient way/query to find related entities

Let's say we have following SQL table structure Entities (5-15k) Keywords (15-20k) EntityKeywords ExcludedKeywords (keywords which should be excluded from common matching) We need to find related ...
6
votes
3answers
859 views

C++ Dependency Injection vs Memory Usage

I have a hypothetical C++ code containing these two classes: Master: it's big, does a lot of things and is meant to have only one instance; Slave: quite the opposite. It can also do a lot of things, ...
0
votes
1answer
188 views

When is return-value optimization used? [closed]

In the code snippet below, I have a class that holds a vector, and a getter to access it. When I compile my code with optimizations turned on, I would have expected that the call to get_value() would ...
1
vote
4answers
235 views

When is it justified to write implicit conditions? [duplicate]

As a rookie programmer, I've only recently been digging into benchmarking, and have been comparing various ways of accomplishing the same task in terms of speed. Most of the time, the result is ...
2
votes
2answers
264 views

Does implementing more interfaces on a class decrease performance?

I had a question regarding the performance of having a class implement multiple interfaces. Is there any degradation in having a class implement 2 interfaces vs 10 interfaces? Background This ...
2
votes
2answers
147 views

Third party dependencies management

I'm looking for a strategy to manage my third party dependencies. I don't mean package managers and vendor techs, I mean a process of making decisions about to add a third party lib or to write ...
3
votes
1answer
160 views

Do any languages make evaluation of the right-hand of an “AND” operation optional?

The C# language has two "AND" operators when dealing with Boolean values, & and &&. (Leaving aside the bit-wise operators.) When the left-hand value is False, the difference between these ...
0
votes
2answers
86 views

Strategies for avoiding expensive batch searches

We have a list of about 100, 000 customers. Every night, we run a batch search of these customer names against a list of known criminals/suspicious persons. This list contains around 1 million entries....
-4
votes
2answers
120 views

Which one of the two is efficient?

I have been reading a blog where the author has mentioned the below two styles of coding. Min and Max 1 int min = Integer.MAX_VALUE; int max = Integer.MIN_VALUE; for (int x : array) { if (x < min)...
-1
votes
2answers
129 views

Database optimization vs readibility

I'm working on some code that checks for some invariants in the database. For example to check that an element is not repeated the code checks for a database error since the invariant is coded at ...
1
vote
1answer
164 views

Moving from Batch to Streaming architecture using a Graph datastructure

The use case I am trying to solve is, assigning millions of users to their groups/segments. I have thousands of different criteria from which buckets of users are created. E.g. bucket criteria: All ...
1
vote
1answer
148 views

Delete parent entity along with child

Scenario: I have a simple text-based post. Which can receive comments and likes. All entities have their own tables. Like and comment generate notifications. Basic Parent-Child RelationShip in ...
7
votes
4answers
2k views

Struct vs class in Swift

One of the stated reasons that structs can be more performant than classes is that no ARC is needed for structs. But suppose we have the following struct in swift: struct Point { var x:Float ...
2
votes
4answers
4k views

Is it good to store comma-separated values in single column?

I know this question has probably been asked several times before, but my question is specific to my situation. I am implementing a notification micro service. It has an email table and a queue table....
3
votes
1answer
417 views

What is the best way to pass errors between PHP pages?

I had some ideas, but which one is the best (and why), and is it other way(s) to do this? I thought about : - Sessions - GET Params, but if there is a lot of errors(for example a register form) ...
-1
votes
4answers
229 views

Best practices for reducing bugs while optimizing code [closed]

Earlier today I was working on a simple program from a textbook. Although I solved the question with confidence and a clear robust solution, the solution wasn't perfect as it had steps which were ...
2
votes
1answer
246 views

Dynamic Scheduling Algorithm

Recently I got interested in scheduling problems or rather dynamic scheduling problem. The problem is that I want to develop some kind of layer in my application which will be polling circa about 50-...
4
votes
5answers
218 views

Optimizing database queries in unit testable code

So let's say you're writing software for some company. Best practices, as I understand them, would dictate that for dev purposes, you populate your DB with fake data. There are a number of benefits to ...
0
votes
1answer
348 views

Data filtering & requests: fetch all entries or split data?

I am in a situation I cannot decide which approach is the most optimal (performance wise) while being maintainable at the same time (in the sense of having a clear logic). The question is laid in the ...
6
votes
3answers
359 views

Why running threaded algorithms with exact number of cores the machine has, is faster than anything else?

I made some basic multi-threading tests here, and noticed that the speed increase when using the exact is bigger than I expected. I assumed that speed would increase linearly until I hit the limit of ...
7
votes
6answers
654 views

Why is it is easier to reason about programming languages and programs that have no side effects?

I read "The Why of Y" from Richard P. Gabriel. It is an easy to read article about the Y combinator, which is quite rare. The article begins with the recursive definition of the factorial function: ...
0
votes
0answers
124 views

Optimizing a client-server visualization that runs out of memory

I have a visualization (shader-based) that I'm running in a Chrome browser. Recently I've been running out of memory after periodically refreshing the pool of data from the server, or if I make the ...