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

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

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

Accurately testing Pypy vs CPython performance

The Problem Description: I have this custom "checksum" function: NORMALIZER = 0x10000 def get_checksum(part1, part2, salt="trailing"): """Returns a checksum of two strings.""" combined_string = part1 + part2 + " " + salt if part2 != "***...
more »

2017-02-07 18:02 (0) Answers

Django queries and joins

I read in the Django documentation that in principle Django queries are lazy, that is the database is not queried until absolutely necessary. Now, as a matter of efficiency, when I retreive data via FooModel.object.filter(...) and I have defined...
more »

2017-02-07 10:02 (3) Answers

When to use `Math.sqrt` vs `**0.5`?

In a back-of-the-envelope performance test in IRB in Ruby 2.1.4*, I noticed that i**0.5 seems to perform a good deal faster than Math.sqrt(i). def benchmark(n, &block) start = (1..n).each(&block) - start end And the...
more »

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

Numpy: What is special about division by 0.5?

This answer of @Dunes states, that due to pipeline-ing there is (almost) no difference between floating-point multiplication and division. However, from my expience with other languages I would expect the division to be slower. My small test looks a...
more »

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

jquery get the first element in document order

Jquery get the first element with a selector: aElement.find(".ui-foo").first(); If the document is big and has many element with ui-foo, the performance is not ideal. JQuery should stop searching after finding the first one. Is there a better way ...
more »

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

numpy: efficient, large dot products

I am trying to perform a large linear-algebra computation to transform a generic covariance matrix KK_l_obs (shape (NL, NL))into a map of covariance matrices in a reduced space Kmap_PC (shape (q, q, X, Y)). Information about how to construct Kmap_PC...
more »

2017-01-30 18:01 (2) Answers

onBackPressed() Best Practice/Performance

I usually override onBackPressed() like this: @Override public void onBackPressed() { super.onBackPressed(); Intent intent = new Intent(getApplicationContext(), HomeActivity.class); startActivity(intent); finish(); } Only now I saw...
more »

2017-01-30 16:01 (1) Answers

NodeJS much slower than PHP?

I run a tiny scale web server under Apache + PHP + MySQL at the moment and would like to explore the option of using NodeJS instead. The server literally does two things: Serve some static files (HTML/CSS/image resources etc) Query the database (se...
more »

2017-01-30 05:01 (1) Answers

Slow len function on dask distributed dataframe

I have been testing how to use dask (cluster with 20 cores) and I am surprised by the speed that I get on calling a len function vs slicing through loc. import dask.dataframe as dd from dask.distributed import Client client = Client('
more »

2017-01-27 20:01 (1) Answers

C# Task.Run slowing my wpf program

Short story: I am designing software to validate some things in a CAD application. When I try parallelism it gets very slow in WPF only. Long story: I have my software that asks questions of my library (.dll) that I also made and that library commun...
more »

2017-01-25 02:01 (2) Answers

Retrieving memory block from binary file

The overall goal is to search and read from a binary file as fast as possible. For a given finite set of parameters, p_1, p_2, ... , p_n, I want to be able to search a binary file and retrieve the contents corresponding to the parameters. The general...
more »

2017-01-23 23:01 (1) Answers

Event Listeners Efficiency

How do event listeners in any programming language actually work internally? The point of this post is to get an overall idea of how event listeners in general work. A while back, when I first started playing with Javascript and Html, every time I ne...
more »

2017-01-23 04:01 (4) Answers