Tag Info

Hot answers tagged

25

There are two 'forces' here, in tension: Performance vs. Readability. Let's tackle the third problem first though, long lines: System.out.println("Good morning everyone. I am here today to present you with a very, very lengthy sentence in order to prove a point about how it looks strange amongst other code."); The best way to implement this and keep ...


20

This is a very bad situation, you need to refactor this ASAP - this is technical debt in it's worst - you don't even know how important the code really is - only speculate that it's important. As to solutions ASAP: Something that can be done is adding a custom compilation step. If you use Maven that is actually fairly simple to do, other automated build ...


15

Is the maintenance hit real, or does it just bother you? If it only bothers you, leave it alone. Is the performance issue real, or did the previous developer only think it was? Performance problems, more often than not, are not where they are thought to be, even when a profiler is used. (I use this technique to reliably find them.) So there is a ...


12

How is this normally done or whats the better approach? The best approach is to try it first without an extra field, measure the performance, and if it really turns out to be too slow, you try to optimize. This could mean to switch to your first approach using an extra field, but you should consider to test other options as well, for example, putting an ...


8

The textbook solution acccording to database theory would be to have no values in your database which depend on the values of other data, because these are transitive dependencies. Having fields which are computed values based on other fields is a violation of normalization, because it leads to redundant information. However, sometimes what the textbook ...


8

Really make sure than under real, production, conditions (realistic memory consumption, that triggers Garbage Collection realistically, etc), all those separate methods really make a performance difference (as opposed to having only one method). This will take a few days out of your time, but may save you weeks by simplifying the code you work with from now ...


6

Why not include some sort of template preprocessor\code generation for this system? A custom extra build step that executes and emits extra java source files before compiling the rest of the code. This is how including web clients off of wsdl and xsd files often works. You'll of course have the maintenance of that preprocessor\code generator, but you ...


5

Sometimes, the specification of an algorithm is based on bit operations. This is especially true in crypto work. Crypto has another attribute to it that is important - that the operation takes exactly the same amount of time no matter what the parameters are. This is to try to avoid leaking any data with timing attacks (there are even attacks based on the ...


4

The potential problem is performance and you don't have a performance problem, yet. There are many things you can do depending on the database of choice to handle this in solution #1: indexing, hardware, caching, etc. This all depends on how frequently the user needs to get a current unread message count. Many of these choices don't require custom coding on ...


4

Compilers are smart beasts. Usually, they'll automatically squeeze out as much performance as they can from anywhere they can. Trying to outsmart the compiler doesn't usually make a big difference, and has a lot of chances to backfire. For instance, inlining makes your program bigger as it duplicates the code everywhere. If your function is used in a lot of ...


4

The inefficiency/messiness is coming from "hydrating" your data too early and too often. By "hydrating," I mean instantiating data objects from (what I assume are) records in your database. You don't always need to deal with data objects. For example, with this code... $posts = Posts::getPosts(); // get the ids into an array $post_ids = array(); ...


3

Another answer gave an excellent overview over how you'd nicely encapsulate the row-oriented storage and give a better view. But since you also ask about performance, let me address that: SoA layout is not a silver bullet. It's a pretty good default (for cache usage; not so much for ease of implementation in most languages), but it's not all there is, not ...


3

When you loaded the definition for your own max function into ghci, you may have not noticed that ghci indicated that it was interpreted (something along these lines): Prelude> :l mymax.hs [1 of 1] Compiling Main ( mymax.hs, interpreted ) Ok, modules loaded: Main. In order to really benchmark performance, compile your definition with ghc ...


3

Short answer: you are fully correct, and articles like this one are completely missing this point. The full answer is: the "Structure-Of-Arrays" approach of your examples can have performance advantages for some kind of operations ("column operations"), and "Arrays-of-Structs" for other kind of operations ("row operations", like the ones you mentioned ...


3

Fragment is a modular section of an Activity that has it's own lifecycle, receives its own input events, which you can add or remove while the activity is running (sort of like a "sub activity" that you can reuse in different activities) Apart from the obvious advantage of using fragments, UI optimization across different screens, it lets you manage ...


2

You are right - there is no way to guarantee that the method would be inlined - MSDN MethodImplOptions Enumeration, SO MethodImplOptions.AggressiveInlining vs TargetedPatchingOptOut. Programmers are more intelligent than a compiler, but we work on a higher level and our optimizations are products of one man's work - our own. Jitter sees what's going during ...


2

What is the best way to get a grip on intended and unintended performance changes in such a setup? I don't know anything about your benchmark suite, but as far as I understand the question, this can be implemented as an automatic test (I assume you have already a test suite with integration or acceptance tests in place). What you need is a ...


2

I believe that the best approach for your case is using Jenkins with the Performance Plugin. It has nice graphs and can be used both with JMeter and SoapUI. Also test performance is important. According to Martin Fowler it is better to run fast unit tests for every commit and slow integration and performance tests every few hours.


2

I have a limited amount of experience with Jenkins. One thing I really liked about it was the dashboard display that had been set up by my colleagues, using plugins for Jira, Subversion, and Clover (code coverage). Jenkins supports quite a number of plugins and you can develop them yourself. I know that Hudson has a similar extensibility.


2

Your original approach does lazy loading while your modified code does eager loading. You are absolutely right that eager loading is more efficient in your situation. In most cases, minimising the number of queries is the best thing you can do to speed up your app. If you were only going to look at one of the posts then lazy loading would be faster. Most ...


1

These stats are for the Model I, and is for two 10 digit numbers. The Model I did in fact use table look ups for math, except for divide (add table was at locations 300-399, multiply at 100-299). The Model II had circuitry for addition and subtraction, but still used table look up for multiply. As odd as all of that sounds what you would find most odd was ...


1

From the previous column in that table, the "1620" is the IBM 1620. https://en.wikipedia.org/wiki/IBM_1620 And yes it means multiplying two numbers.


1

What you have described is an implementation problem. OO design is expressly not concerned with implementations. You can encapsulate your column-oriented Ball container behind an interface that exposes a row- or column-oriented view. You could implement a Ball object with methods like volume and move, which merely modify the respective values in the ...


1

I don't think having a bunch of printlns is a design issue at all. The way I see it is that this can clearly be done with static code analyzer if it is really a problem. But it is not a problem because most people don't do IOs like this. When they really need to do lot of IOs, they use buffered ones (BufferedReader, BufferedWriter, etc..) when the input is ...


1

While the performance is not really an issue here, the bad readability of a bunch of println statements points to a missing design aspect. Why do we write a sequence of many println statements? If it were just one fixed text block, like a --help text in a console command, it would be much better to have it as a separate ressource and to read it in and write ...


1

In higher level languages like C and C++, this is less of a problem than in Java. First of all, C and C++ define compile-time string concatenation, so you can so something like: std::cout << "Good morning everyone. I am here today to present you with a very, " "very lengthy sentence in order to prove a point about how it looks strange " ...


1

Many mathematical operation (such as division, multiplication, etc.) are supposed to be computed faster when dealing with power of two numbers. For instance 15 * 256 = 0x0e right shifted (fast) 8 bits = 0x0e00 = 3840 Whereas 15 * 255 = 0x0e multiplied by (slow) 0xff = 0x0ef1 = 3825 Does this kind of optimization even happen in SQL Server? ...


1

You might want to check whether you can still use some sensible abstractions and use e.g. the template method pattern to write understandable code for the common functionality and move the differences between the methods into the "primitive operations" (according to the pattern descrition) in 12 subclasses. This will mightily improve maintainability and ...


1

No sane Java method can be long enough to have 12 variants... and JITC hates long methods - it simply refuses to optimize them properly. I've seen a speed up factor of two by simply splitting a method into two shorter ones. Maybe this is the way to go. OTOH having multiple copies may make sense even if there were identical. As each of them gets used in ...


1

On Windows, at least, guard pages are considered too "expensive" to use them for every allocation. So guard pages are more of a backup. They are only used for large allocations. Also, they cause problems for 32-bit applications, because they consume virtual memory address space. You can read more here: Software Defense: mitigating heap corruption ...



Only top voted, non community-wiki answers of a minimum length are eligible