Ways to optimise this code

I am exploring ways to optimise the code that follows. The code loops over a string. For the ith character in the string, the code increments one entry in a 2D array at the ith column. The exact entry at the ith column that is incremented depends on...
more »

2017-05-26 21:05 (2) Answers

How to randomly shift rows of a numpy array

I am looking for a more pythonic way of randomly shifting rows of a numpy array. The idea is that I have an array of data, and I want to left-shift each row of the array by a random amount. My solution, which works, but I feel is a bit un-pythonic: ...
more »

2017-05-24 00:05 (1) Answers

Can I further simplify this code/expression?

I'm in a DSP context, which I need to speed-up some operations. Here's a formula I have and I execute often: unsigned int pos0 = (unsigned int)round((envelope.mLengths[sectionIndex] * mSampleRate) / gBlockSize) * gBlockSize; unsigned int pos1 = (un...
more »

2017-05-22 13:05 (2) Answers

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