Tag Info

New answers tagged

2

While reflection is slow, doing it a handful of thousand times while processing a file will probably not be an issue: the file access is likely to be slower still. Still, you should be able to improve the performance of the code you posted by moving the initiation of ' field' outside of your loop.


5

Short answer: no. Long answer: I assume when you write "size" of an object, you mean size (in bytes) of the member variables, and when you write "complexity", you mean number of members, number of different types used, and so on. Access to an object through a member function will result in IL code which contains pushing the parameters of the method to ...


1

My organization has dealt with this exact problem. Our products are in the video space, but much of the code we write is image processing that would work for still images, too. We "solved" (or maybe "dealt with") the problem by writing our own compiler. This isn't quite as crazy as it sounds at first. It's got a restricted set of inputs. We know that all ...


-1

I've done assembly programming in the past, not SIMD programming recently. Have you consider using a SIMD-aware compiler like Intel's? Is A Guide to Vectorization with Intel® C++ Compilers interesting? Several of your comments like "balloon-popping" suggest using a compiler (to get benefits throughout if you don't have a single hot-spot).


11

Since you are using this information for billing purposes, I do not see why you would not want it in the database where it can be easily queried, aggregated, reported on, and joined to other data. I also think it's much easier to maintain a single database table containing the log information than a bunch of separate log files. Same with your concern ...


0

If you have control over any of the apis, and for your own api if you are expecting the browser to display "live" updates, you may want to consider implementing "long polling", also known as "comet". In long polling, whena request is made, the server checks to see if anything has changed since the client last polled (it can be helpful if the client includes ...


1

Having just tested it on a variety of images from a couple of web sites I maintain, I can state that I won't be using it because it seems to do nothing useful: it was unable to achieve any savings for any of the four images I gave it (two JPEGs and two PNGs). I had taken no special steps to optimize these images, just saving them in the most appropriate ...


13

How is it possible to reduce an image by 90% without losing quality? Formats and compression options There are three popular image storage formats for web (not counting the promising WebP), and each format has its own compression options. A clueless coder may pick the wrong format and use wrong options, resulting in less-than-optimal image quality and ...


-2

As others already noted, Ttese code will have different results, if either dosomethingelse or dootherstuff throw an exception. And yes, any function call can throw an exception, at least a StackOVerflowError! While it is rarly possible to handle these correctly (as any called cleanup function will probably have the same issue, in some cases (such as ...


-1

It doesn't seem to add too much maintenance overhead if you consider using a higher-level language: Vector<float> values = GetValues(); Vector<float> increment = GetIncrement(); // Perform addition as a vector operation: List<float> result = (values + increment).ToList(); vs List<float> values = GetValues(); List<float> ...


4

I did not write much SIMD code for myself, but a lot of assembler code some decades ago. AFAIK using SIMD intrinsics is essentially assembler programming, and your whole question could be rephrased just by replacing "SIMD" by the word "assembly". For example, the points you already mentioned, like the code takes 10x to 100x to develop than "high level ...


2

EDIT: I realize my answer didn't exactly answer the question, while there is no real downside, from my timing results there is no real upside either. The difference between a inline property getter is 0.002 seconds over 500 million iterations. My test case may also not be 100% accurate since its using a struct because there are some caveats to the jitter and ...


1

Here is a simple improvement which will most probably meet your time constraints. For every divisor i of N, there is also a corresponding divisisor N/i. And to find all pairs of divisors, you need only to loop from 1 to the square root N. So try something along the lines of int maxD = (int)Math.sqrt(input); int sum=1; for(int i = 2; i <= ...


1

A much more efficient way would be to factorize the number into prime factors (using existing libraries, although I do not know one by heart). Say the factorization is a HashMap<Integer,Integer> factorization where each prime factor is mapped to its multiplicity, then one can compute your sum as follows. int N = 84684684; //your integer ...


5

I believe you misunderstood the recommendations for logging. The 12 Factor site states A twelve-factor app never concerns itself with routing or storage of its output stream. It should not attempt to write to or manage logfiles. Instead, each running process writes its event stream, unbuffered, to stdout. During local development, the developer will ...


0

Note that the pseudo-code in wiki is not practical. It is written to undestand. If an array is [0,0,0,1] pivot is 1 and other elements are less than the pivot, then swapping(t <-- a, a <-- b, b <--t) works as t <-- a, a <-- a, a <-- t. In this case swapping works nothing. If an array is [4,2,1,3] then [4,2,1,3] --> [2,4,1,3] --> [2,1,4,3] ...



Top 50 recent answers are included