Optimizing adding dashes to a long Swift String

I am trying to take a hex string and insert dashes between every other character (e.g. "b201a968" to "b2-01-a9-68"). I have found several ways to do it, but the problem is my string is fairly large (8066 characters) and the fastest I can get it to w...
more »

2017-05-19 00:05 (2) Answers

Vectorize python code for improved performance

I am writing a scientific code in python to calculate the energy of a system. Here is my function : cte1, cte2, cte3, cte4 are constants previously computed; pii is np.pi (calculated beforehand, since it slows the loop otherwise). I calculate the 3 c...
more »

2017-05-14 11:05 (1) Answers

Optimization of speed in R

I am currently working on a function that works on a big matrix of 2 columns ( number of values > 2000 in general) and have a time problem. here the head of my matrix : matrix here my function : get <- function() { v <- sample(1:1e6,2000...
more »

2017-05-10 15:05 (2) Answers

Performance Optimisation

I have this bit of my code which takes like 90 % of the runtime. There are about 8000 rows and information are stored in column A. This bit of code is splitting this information in the other columns. It takes approximately 15 mins to run ( :O ). Any...
more »

2017-05-10 10:05 (1) Answers

conditional select statement in oracle

I have two tables called order and public holiday as following: Order Table: OrderId OrderDate --------------------------- 1 10 Mar 2017 2 12 Mar 2017 3 30 Mar 2017 Public Holiday Table: HoliId | Holiday...
more »

2017-05-08 16:05 (3) Answers

Jquery: Dynamically load set of images

Context: I am developing a company website in Phases due to launch deadline. Phase 1 is to develop the site's front-end and "hard-code" all content. Phase 2, post-launch, is to integrate developed site into a CMS back-end, wordpress, to handle presen...
more »

2017-05-02 21:05 (1) Answers

ClassName::class vs 'ClassName' in PHP

In one of my projects we are having a function which validates objects like: if( true == valObj( $someObj, 'SomeClass' ) ) { //Do some work; } While using this I thought this can be written like: if( true == valObj( $someObj, SomeClass::class...
more »

2017-04-26 15:04 (3) Answers

Prior writing to input buffer slows down algorithm

I have a couple of image filter algorithms to optimize. The code is written in ARM/NEON assembler, but meanwhile I doubt that this is related to the problem I'm facing. I made the observation that the time it takes to process an image heavily depend...
more »

2017-04-25 10:04 (0) Answers

Fast I/O in c, stdin/out

In a coding competition specified at this link there is a task where you need to read much data on stdin, do some calculations and present a whole lot of data on stdout. In my benchmarking it is almost only i/o that takes time although I have tried ...
more »

2017-04-23 17:04 (2) Answers

Why gcc isn't optimizing the global variable?

I am trying to understand the behavior of volatile and compiler optimization in C through an example. For this, I referred: Where to use volatile? Why is volatile needed in C? https://software.intel.com/en-us/blogs/2007/11/30/volatile-almos...
more »

2017-04-23 14:04 (1) Answers

Conditional bit setting

From my small research, the two functions below are equivalent (from performance point of view) because even very light optimization (-O1) results in the identical assembly code. Code 1: #define BIT_N (10) extern unsigned int isBitSet; unsigned i...
more »

2017-04-21 11:04 (3) Answers

Threads on same core accessing same cache line

I am working in a bare-metal environment and thus evaluating performance at a low-level. How should I expect two threads on the same core to perform when writing to different sections of the same cache line? I am somewhat new to multicore/multithrea...
more »

2017-04-19 18:04 (1) Answers

Multithreading - Raytracer

I've finished my raytracer now but im trying to learn threads to optimize the render time. To represent each pixels of my window im using a int8_t * (4 int8_t / pixel for R/G/B/A). Here is a sample of what im trying to do : Number of threads set : 4...
more »

2017-04-18 23:04 (1) Answers

React Dont Rerender Existing DOM Children

How can I render a react element without rerendering existing child content? I am not looking to avoid rerendering an existing react child, as in my case there are no existing react children, because the html came directly from the server. For exam...
more »

2017-04-16 01:04 (0) Answers

Optimize summation code

Its from an interview: int fn(int a, int b) { int sum = 0; for (int i = a * 4; i>0; i--) { sum += b*i*i; } return sum; } How can this code be further optimized? I know there is a summation formula, but I dont think...
more »

2017-04-14 05:04 (4) Answers