Posts

Showing posts with the label performance

Why is the GNU scientific library matrix multiplication slower than numpy.matmul?

12 2 Why is it that the matrix multiplication with Numpy is much faster than gsl_blas_sgemm from GSL, for instance: import numpy as np import time N = 1000 M = np.zeros(shape=(N, N), dtype=np.float) for i in range(N): for j in range(N): M[i, j] = 0.23 + 100*i + j tic = time.time() np.matmul(M, M) toc = time.time() print(toc - tic) gives something between 0.017 - 0.019 seconds, while in C++: #include <chrono> #include <iostream> #include <gsl/gsl_matrix.h> #include <gsl/gsl_blas.h> using namespace std::chrono; int main(void) { int N = 1000; gsl_matrix_float* M = gsl_matrix_float_alloc(N, N); for (int i = 0; i < N; i++) { for (int j = 0; j < N; j++) { gsl_matrix_float_set(M, i, j, 0.23 ...

Comparing Fortran & C++ assembler for int = floor(sqrt(…))

37 6 I have implemented a function in Fortran and C++ each: #include <math.h> void dbl_sqrt_c(double *x, double *y){ *y = sqrt(*x - 1.0); return; } pure subroutine my_dbl_sqrt(x,y) bind(c, name="dbl_sqrt_fort") USE, INTRINSIC :: ISO_C_BINDING implicit none real(kind=c_double), intent(in) :: x real(kind=c_double), intent(out) :: y y = sqrt(x - 1d0) end subroutine my_dbl_sqrt I compared them in the compiler explorer: Fortran: https://godbolt.org/z/froz4rx97 C++: https://godbolt.org/z/45aex99Yz And the way I read the assembler, they do basically the same thing, but C++ checks whether the argument of the sqrt is negative, which Fortran doesn't. I compared their performance using googles benchmark, but they are pretty evenly...

React native real time chart

I am facing some performance issues when trying to draw real-time chart using various libraries for data visualization in react native based mobile app. I tried multiple libraries like react native chart2, react-native-pathjs-charts, arty-charty etc. but all in vain. Is it React Native issue or just simple i could find right library ? PS: I get data every 500 ms, 1000 ms, 2000 ms in my mobile app. For example using, react-native-chart2 //In Render function, i have below source <RNChart style={styles.rnchart} chartData={chartData} verticalGridStep={50} gridColor={'white'} labelTextColor={"white"} showYAxisLabels={false} xLabels={xAxisTime}/> //In data receive event callback, i have below source let newArr1 = yAxisDataArr.slice(sliceFrom); newArr1.push(currntMa); newArr1.push(currntMa/4); yAxisDataArr = newArr1; chartData = [ { name:'LineChart', //color:'gray', lineWidth:2, showDataPoint:false, data:yAxisDataArr } ]; this._tick()...

React Native Android performance

Are there any benchmarks of how React Native Android performance compares to traditional native Android apps? https://code.facebook.com/posts/895897210527114/dive-into-react-native-performance/ implies the performance has improved but it would be nice to know actual numbers, especially on older Android phones.

React Navigation vs. React Native Navigation

I just wanna to know honest, experienced and objetive points of view about these two soutions to implement the navigation in React Native: React Navigation React Native Navigation Which its better and why. Thanks React Native Navigation as the name says uses the native modules with a JS bridge, so performance will/may be better. [Used by a large proportion out there]. requires native integration. While React Navigation is a simple and powerful solution provided by react native itself. Its an all JS implementation unlike the other that uses native support which can be tricky. Just npm-install and you're go to go ... Use react navigation if you prefer an all JS implementation and use native navigation if your highest priority lies in performance . Both libs are one of the best navigation solutions for React Native. Use it according to your needs. UPDATE : Both libs have undergone drastic changes and entered v2. react-navigation is more stable and perfo...

MongoDB Java API slow reading peformance

We are reading from a local MongoDB all documents from a collections and performance is not very brillant. We need to dump all the data, don't be concerned why, just trust it's really needed and there is no workaround possible. We've 4mio documents that look like : { "_id":"4d094f58c96767d7a0099d49", "exchange":"NASDAQ", "stock_symbol":"AACC", "date":"2008-03-07", "open":8.4, "high":8.75, "low":8.08, "close":8.55, "volume":275800, "adj close":8.55 } And we're using this for now trivial code to read: MongoClient mongoClient = MongoClients.create(); MongoDatabase database = mongoClient.getDatabase("localhost"); MongoCollection<Document> collection = database.getCollection("test"); MutableInt count = new MutableInt(); long start = System.currentTimeMillis(); collection.f...

Why does Haskell use mergesort instead of quicksort?

In Wikibooks' Haskell, there is the following claim: Data.List offers a sort function for sorting lists. It does not use quicksort; rather, it uses an efficient implementation of an algorithm called mergesort. What is the underlying reason in Haskell to use mergesort over quicksort? Quicksort usually has better practical performance, but maybe not in this case. I gather that the in-place benefits of quicksort are hard (impossible?) to do with Haskell lists. There was a related question on softwareengineering.SE, but it wasn't really about why mergesort is used. I implemented the two sorts myself for profiling. Mergesort was superior (around twice as fast for a list of 2^20 elements), but I'm not sure that my implementation of quicksort was optimal. Edit: Here are my implementations of mergesort and quicksort: mergesort :: Ord a => [a] -> [a] mergesort [] = [] mergesort [x] = [x] mergesort l = merge (mergesort left) (mergesort right) where size = div...