Lapply vs for loop - Performance R

It is often said that one should prefer lapply over for loops. There are some exception as for example Hadley Wickham points out in his Advance R book. (http://adv-r.had.co.nz/Functionals.html) (Modifying in place, Recursion etc). The following is o...
more »

2017-02-22 15:02 (1) Answers

Chrome slow to load resources `(from disk cache)`

My site http://www.front-end.io configures the HTTP requests to load resources from cache with first priority. So my header will be like: cache-control:max-age=315360000 ETag:W/"11913b-ks0rwRQM+ijHcl1HDuse3g" Chrome indeed does not initiate any re...
more »

2017-02-22 13:02 (1) Answers

How to speed up one hot encoder code

I made simple function that will return an output one hot encoded matrix when given as input one vector. import numpy as np def ohc(x): u = list(set(x)) c = len(u) X = np.zeros((len(x), c)) for idx, val in enumerate(x): for ...
more »

2017-02-19 23:02 (3) Answers

Fast points in circle test with numpy

I have a large number of (x,y) grid points with integer coordinates which i want to test if they are in small number of circles given by radius and center. The points are some marked parts of an image, which means there are a small number of irregula...
more »

2017-02-19 20:02 (1) Answers

Improve caching performance in Mule

I am using Anypoint 6.1 and Mule 3.8.1 and I'm finding problems with the performance and it looks like it is down to the cache scope. The cache is a managed store (so I can invalidate the cache when new data is loaded) and has the following values...
more »

2017-02-17 17:02 (0) Answers

How to measure DOM rendering time Angular 2 app?

While I am develping web application using Angular 2, I came to have question about performance test like how to measure loading time in Angular2?. Therefore, I got a very helpful answer, I could start to do performance test. However, I would like to...
more »

2017-02-16 20:02 (0) Answers

OOP design: cache data

I want to design a program so that I can efficiently fetch and display data for users. The steps are: users specify some settings (SettingOne, SettingTwo, SettingThree...); load different data from database according to different settings; display...
more »

2017-02-15 23:02 (0) Answers

Haskell/GHC performance of `any'/`all'

I wrote universal quantification functions exists, forall, and none for Haskell's build-in [] linked list data type. On multiple occasions, these proved much more (time) efficient than Prelude/Data.Lists any and all. I suspect that this performance i...
more »

2017-02-15 12:02 (1) Answers

TreeSet vs Java 8 Streams performance

Which way is the most efficient to process a distinct and sorted collection? 1. Enhanced loop with TreeSet Set<MyObj> ret = new TreeSet<>(); for (Foo foo : foos) ret.add(new MyObj(foo)); 2. Simple Stream List<MyObj> ret...
more »

2017-02-15 08:02 (3) Answers

Fast way to decode RGB image in python

I have a PNG image with the dimensions 1024x1024 that contains RGB encoded elevation data. I read in the image using asarray from numpy: rgb_data = np.asarray(image) Which results in an 3D array with dimensions (1024, 1024, 4). (I'm using RGBA) I...
more »

2017-02-14 14:02 (2) Answers

#define efficiency in C

I'm new to C and was wondering which is the more efficient or preferred way to program the following: Option A: #define flag true void Foo() { for (size_t i = 0; i < veryBigNumber; i++) { if (flag) doSomething1(); doS...
more »

2017-02-13 11:02 (6) Answers

Simulating Data Efficiently with data.table

I am trying to simuate a new dataset from two smaller datasets. It is important for me to maintain the marginal counts from these smaller datasets in the final dataset. Hopefully this reproducible example should explain what I mean. Build fake data ...
more »

2017-02-09 22:02 (0) Answers

Avoid Numpy Index For loop

Is there any way to avoid using a second for loop for an operation like this? for x in range(Size_1): for y in range(Size_2): k[x,y] = np.sqrt(x+y) - y Or is there a better way to optimize this? Right now it is incredibly slow for larg...
more »

2017-02-09 21:02 (2) Answers

Perlbrew and cpan are very slow on OSX Sierra

I've just installed perlbrew on a Mabcook Pro 2016 running OSX Sierra 10.12.3. Launching cpan is extremely slow. It just hung there for about 2 minutes before the prompt showed up. I then ran 'install CPAN' and that took at least another 3-4 minutes ...
more »

2017-02-09 17:02 (1) Answers

Improve performance of reading volatile memory

My first question so I'll try to do my best: I have a function reading from some volatile memory which is updated by a DMA. The DMA is never operating on the same memory-location as the function. My application is performance critical. Hence, I rea...
more »

2017-02-09 14:02 (5) Answers

EF6 Query Plan Caching

Query Plan Caching The first time a query is executed, it goes through the internal plan compiler to translate the conceptual query into the store command (e.g. the T-SQL which is executed when run against SQL Server). If query plan caching...
more »

2017-02-09 01:02 (0) Answers

Fast numpy roll

I have a 2d numpy array and I want to roll each row in an incremental fashion. I am using np.roll in a for loop to do so. But since I am calling this thousands of times, my code is really slow. Can you please help me out on how to make it faster. My...
more »

2017-02-07 23:02 (2) Answers

Query does full table scan even with indexes

I am having a simple query with all joined columns indexed but still i receive a full table scan Following is the query select rsb.REP_STATUS_BRIDGE_ID from REP_STATUS_BRIDGE_DETAILS rsd, rep_status_bridge rsb where rsd.REP_STATUS_...
more »

2017-02-07 15:02 (1) Answers