## Web Performance API includes fileSize?

i just started to create RUM script: im using window.performance javaScript object window.addEventListener('unload', logData, false); function logData() { var body = {}; body.timestamp = Date.now(); body.operatingSystem = navigator.plat...
more »

## Python: The function trend to be slow

I need to call a function in for loop. In the first about 200 iteration, the function cost about 0.2s each time. However, the function will cost about 13s each time after 200 iteration. Just like: time cost: 0.194762, 55.968955~56.163716 290 time co...
more »

## Will fseek back to the previous location be faster than seeking to a new location?

If I have a C code off_t off = ftello(f); fseeko(f, some_location); // do some work fseeko(off); Is the second fseeko as slow as the first one? I had thought the file blocks are always cached, so the second one could be much faster. In my profi...
more »

## Which algorithm is faster to sort these number pairs?

I wrote two solutions in python.. It is supposed to take a list of numbers and sort the ones that add up to a sum, both these return the same pairs, but which one is more efficient? I'm not sure if using python's count method does more work behind th...
more »

## Vectorized version of finding the maximum positive value or else the minimum negative value

Let's say I have a pandas DataFrame called purity_list as follows: In[]: purity_list Out[]: 48 49 50 2 0.1 0.9 0.3 A 0.2 -0.5 -0.6 4 0.3 0.8 0.9 I would like to compare this to another numpy array and get the maximum +v...
more »

## Nested rolling sum in vector

I am struggling to produce an efficient code to compute the vector result r result from an input vector v using this function. r(i) = \sum_{j=i}^{i-N} [o(i)-o(j)] * exp(o(i)-o(j)) where i loops (from N to M) over the vector v. Size of v is M&...
more »

## Improve Looping Efficiency in VBA

I have a For loop that loops through integers 1 to 9 and simply finds the bottom most entry that corresponds to that integer ( i.e. 1,1,1,2,3,4,5 would find the 3rd "1" entry) and inserts a blank row. I concatenate the number with a string "FN" that ...
more »

## Neo4j cache and performance

I'm testing a query in neo4j and I see that when I clear the cache . Neo4j takes more time to load . which mean performances are dicreasing . Why is this happening I don't know now whether to clear the cache for each query ? or should I just test w...
more »

## Apply Numpy to "for loops"

import numpy as np c=[10,2000] # only two index for example horizontal=[] vertical=[] for i in range(0,c[0]): for j in range(0, c[1]): horizontal.append(j) vertical.append(i) print horizontal When I am working with arrays a...
more »

## Why is speedglm slower than glm?

I am trying to use speedglm to achieve a faster GLM estimation than glm, but why it is even slower? set.seed(0) n=1e3 p=1e3 x=matrix(runif(n*p),nrow=n) y=sample(0:1,n,replace = T) ptm <- proc.time() fit=glm(y~x,family=binomial()) print(proc.tim...
more »

## vectorise for loop with numpy.where

>>> a = np.array([1, 1, 2, 3, 3, 4, 5]) >>> b = np.array([1, 3, 4, 5]) >>> indices = np.zeros((len(a))) >>> for i in range(len(a)): try: indices[i] = np.where(b == a[i])[0][0] except: indice...
more »

## Why is numpy's exp slower than Matlab? How to make it faster?

I have a pretty simple example which shows that NumPy's np.exp is about 10x slower than Matlab. How can I speed up Python? I'm running 32bit Python 2.7, NumPy version 1.11.3, and numpy is using the MKL blas & lapack libraries. Also, the differe...
more »

## Fastest way to read in and slice binary data files in Python

I have a processing script that is designed to pull in binary data files of type "uint16" and do various processing in chunks of 6400 at a time. The code was originally written in Matlab, but because the analysis codes are written in Python we wanted...
more »

## Calculate histograms along axis

Is there a way to calculate many histograms along an axis of an nD-array? The method I currently have uses a for loop to iterate over all other axes and calculate a numpy.histogram() for each resulting 1D array: import numpy import itertools data = ...
more »

## Fastest way to calculate difference in all columns

I have a dataframe of all float columns. For example: import numpy as np import pandas as pd df = pd.DataFrame(np.arange(12.0).reshape(3,4), columns=list('ABCD')) # A B C D # 0 0.0 1.0 2.0 3.0 # 1 4.0 5.0 6.0 7.0 # 2 8.0 ...
more »

## The accessing time of a numpy array is impacted much more by the last index compared to the second last

This is a follow up to this answer to my previous question Fastest approach to read thousands of images into one big numpy array. In chapter 2.3 "Memory allocation of the ndarray", Travis Oliphant writes the following regarding how indexes are acces...
more »

## What's an easiest way to make sure my key is always first in a javascript object?

I have an object that varies in values and order of keys. var obj = { extension50: {}, extension55: {}, main: {} } Note I have "main" key placed out of order. It should be placed in the beginning so when someone iterates through keys of this objec...
more »

## how to fix rollover with python data

Let's say I've got this csv file that I want to import and graph in python using pyplot and pandas. 1,2 2,4 3,3 4,4 5,6 6,3 7,5 8,6 1,3 2,5 3,7 4,4 5,3 6,5 7,4 8,5 1,3 2,2 3,5 4,4 5,3 6,5 7,6 8,7 As you can see, column 1 rolls over at the number 8...
more »

## Function executes faster on subsequent runs

I was playing with performance.now() and wrote a simple recursive function to calculate the factorial of a number when I ran into some interesting observations. The following code finds the factorial of a number and logs the time it took for the fun...
more »

## Fastest approach to read thousands of images into one big numpy array

I'm trying to find the fastest approach to read a bunch of images from a directory into a numpy array. My end goal is to compute statistics such as the max, min, and nth percentile of the pixels from all these images. This is straightforward and fast...
more »

## Fastest way to compute the opposite of the sign of a number in C

We all know sgn() function. It can be implemented in C like something along these lines: inline int sgn(int x) { if(x > 0) { return 1; } else if(x < 0) { return -1; } else { return 0; } } Or, a more ef...
more »

## Difference between protractor and jQuery selector

Is there any difference between the jQuery selector and the protractor selector. I know that for basic element selection like grabbing a div or paragraph both works fine but do we have a use case where protractor supersede jQuery selector and any spe...
more »

## Which one is better to use in C and C++ programming?

Is there any difference between the following two code snippets? Which one is better to use? Is one of them faster? case 1: int f(int x) { int a; if(x) a = 42; else a = 0; return a; } case 2: int f(int x) { ...
more »

## Why is Gradle build of Kotlin source code pausing for ~3 secs "forcing System.gc()"?

Every build takes an extra 3-4 seconds, pausing immediately after the log output prints the following. [LIFECYCLE] [org.jetbrains.kotlin.gradle.plugin.KotlinGradleBuildServices] Forcing System.gc() Why is it "forcing" this? How do I avoid t...
more »

## ./Gradlew Build is taking 2 hours and 40 minutes - Is there any room for improvement?

The app that we are working on is not very large - most of it is an empty application that gets filled in from various endpoints (server side), but we currently have 18 separate flavors of the app that get built. The issue is, there will be 78 flavo...
more »

## Random mmaped memory access up to 16% slower than heap data access

Our software builds a data structure in memory that is about 80 gigabytes large. It can then either use this data structure directly to do its computation, or dump it to disk so it can be reused several times afterwards. A lot of random memory access...
more »

## How are numpy functions so much faster. As an example I am attaching the following code to see the time difference

def nonzero(a): row,colum = a.shape nonzero_row = np.array([],dtype=int) nonzero_col = np.array([],dtype=int) for i in range(0,row): for j in range(0,colum): if a[i,j] != 0: nonzero_row = np.a...
more »

## How to secure shared preference data in android 4.1 above without storing a key and without fetching key online?

Hello all Big brain developers :-) I want to secure the shared preference data where I have AuthId of user. public static void setUserAuthorization(Context context, String token) { SharedPreferences sharedPreferences = context.getSharedPr...
more »

## Optimize Multiple database update

I am using laravel in my app. So now I need to update many rows on DB once a day with Cron job. If I will use the update option built-in laravel I need to do something like this: // for example, the update info in array \$arrayToUpadte = [ [ ...
more »

Background: Using EntityFramework 6 I'm creating a repository that holds in memory all its entities, for a performance reason, so I need after SaveChange update my "repository cache" public class Person { public decimal Incomes{get; set;} pu...
more »

## best way to evaluate react js app performance

I have huge react app with 50 routes and almost 3000 components. now my question is, how can I check is my app performing well? which modules are taking time. total app's performance indicator how to identify. what are the best tools in the market? ...
more »

## Efficiently converting a Series of dictionaries to a DataFrame

I have a large (ish) Series of dictionaries that I'd like "flatten". In order to test / reproduce my problem I have created a Series with a similar structure: >>> my_series = pd.Series([{'A': [1], 'B' : []}, {'A' : [1, 2], 'B' : [3, 4]}]) &...
more »

## Efficiently reshaping arrays in a pandas dataframe column

I've got a following question: Let's consider a pandas dataframe like this: Width Height Bitmap 67 56 <1d numpy array with length 67 * 56> 59 71 <1d numpy array with length 59 * 71> 61 73 <1d numpy array with ...
more »

## Any performance difference when returning from switch block?

Is there any (possible) performance difference between following switch statements or they are completely equivalent? I've not found any significative difference when profiling them, but I'm still curious if any compiler/flag may improve it if using...
more »