I have in my java app a loop that adds object arrays into a list  List&lt;Object[]&gt; list = new ArrayList&lt;Object[]&gt;();   I noticed that NOT giving an initial capacity was actually faster than giving the capacity.  I have a 23 seconds  vs 15 seconds difference.  I've created this dummy JUnit test to mock that and go 6 seconds vs 6.7 seconds difference, favoring the NO initial capacity:  @Test public void asdf() {      int rowSize = 20;     int rowCount = 10000000;      // DATA PREP     int[][] matrix = new int[rowCount][];     for (int i=0; i&lt; matrix.length; i++) {          matrix[i] = new int[rowSize];         for (int j=0; j&lt; rowSize; j++) {             matrix[i][j] = (int) (Math.random()*10);         }     }      BiFunction&lt;Integer, Integer, Object&gt; getValue = new BiFunction&lt;Integer, Integer, Object&gt;() {         @Override         public Object apply(Integer row, Integer col) {             return matrix[row][col];         }     };      //END DATA PREP      long start = System.currentTimeMillis();      // THIS IS THE DIFFERENCE!!!!     //List&lt;Object[]&gt; lst = new ArrayList&lt;&gt;(rowCount);     List&lt;Object[]&gt; lst = new ArrayList&lt;&gt;();      for (int i = 0; i &lt; rowCount; i++) {         Object[] row = new Object[rowSize];          for (int j = 0; j &lt; rowSize; j++) {             row[j] = getValue.apply(i, j);         }          lst.add(row);     }      long totalTime = System.currentTimeMillis() - start;      System.out.println(totalTime); }        How does it make any sense?  I know generally this code is crap, It's just trying to mock my real case, reading off a resultset (not the jdbc one).  Thanks!
How do you write (and run) a correct micro-benchmark in Java?  I'm looking for some code samples and comments illustrating various things to think about.  Example: Should the benchmark measure time/iteration or iterations/time, and why?  Related:
$\int_{0}^{\infty} \frac{\cos x - e^{-x}}{x} \mathrm dx$ Evaluate Integral Evaluate $$\int_{0}^{\infty} \frac{\cos x - e^{-x}}{x} \ dx$$ External hard drive very slow to load after dropping it and can't be repaired with Disk Utility Today as I was using my WD HDD, it fell off my corner. After I fixed the thing, I plugged it into the Mac and it loads the HDD but it's very very very very slow. It also does not work sometimes. The entire laptop just hangs  Tried running Disk Utility First Aid but it won't work.  It says some error and hangs  Can someone advise me on what I can do in this case? Updated WiFi fix for Yoga 13 and Ubuntu 16.04? Some movies feature child characters put in violent situations. This can range from crude language to extreme horror (e.g. torture, gore, etc.). As an example,  and its sequel has plenty of those scenes. It looks like a paradox that children can be actors in movies that are definitely not for children.  Do the directors usually try and avoid exposing the very young actors to the violence of such scenes, e.g. by clever dubbing and editing? Are there laws that require them to do so, just like there are ratings that prevent children from seeing some movies? Restore Macintosh HD to its original partition configuration Proving Pascal's Rule : ${{n} \choose {r}}={{n-1} \choose {r-1}}+{{n-1} \choose r}$ when $1\leq r\leq n$ Characterizing all ring homomorphisms $C[0,1]\to\mathbb{R}$. This is something I've been trying to work out this evening.      Let $R$ be the ring of continuous real-valued functions on $[0,1]$ with pointwise addition and multiplication. For $t\in [0,1]$, the map $\phi_t\colon f\to f(t)$ is a ring homomorphism of $R$ to $\mathbb{R}$. I'm trying to show that every ring homomorphism of $R\to\mathbb{R}$ has this form.   Suppose otherwise, that there is some $\phi\neq\phi_t$, and thus there is some $f_t\in R$ such that $\phi(f_t)\neq \phi_t(f_t)=f_t(t)$. Define $g_t=f_t-\phi(f_t)1\in R$. Here $\phi(f_t)1$ is the constant function sending $[0,1]$ to $\phi(f_t)$. Then $g_t(t)\neq 0$. My first small question is why does $\phi(g_t)=0$? It seems only that $\phi(g_t)=\phi(f_t)-\phi(\phi(f_t)1)$.  I would like to conclude that there are only finitely many $t_i$ such that $g(x)=\sum g_{t_i}^2(x)\neq 0$ for all $x$. Then $g^{-1}=1/g(x)\in R$, but $\phi(g)=0$, contradicting the fact that homomorphisms map units to units. How can we be sure there are only finitely many $g_{t_i}$ such that the sum of their squares is never $0$? Thanks. I'm trying to find a copy of 6.20 to run a diff on a client's Drupal install. I believe there's been changes to core.   How can I get version 6.20? Additionally, how can I download any older Drupal versions? I flew a long range flight carrying my laptop, a quite heavy one, inside a neoprene briefcase in the passenger cabin. The recommendation by the aircrew was to place it in the overhead compartment or under the seat in front of me. However, during take-off and landing, the vibrations on the plane are quite strong and, as a result, it received minor damage.   Placing them in the overhead compartment might be equivalent to placing it on the floor under the seat, with the added issue of additional luggage in the compartment shifting.  I considered the alternative of holding the laptop by the handle while sitting, so it won't be any contact with the aircraft's floor. This is impracticable during cruise, but I thought it could be better during the take-off and landing segments. Another option I considered is to wrap it with completely with bubble wrap before boarding the plane.   Which is the safest way to transport a laptop during flight? How to saveHTML of DOMDocument without HTML wrapper? How do you set password-hash for OpenLDAP? Showing $\sum\limits_{p \in P} \frac{1}{p}$ where $P$ is the set of all primes is divergent I have a couple of questions about light here, and sorry of they are silly..  So since anything that goes beyond the event horizon can't go out, so what if a light beam was pointed somewhere behind the event horizon to the outside, would light have a slower speed then get sucked back? and what if the light particles were somehow exactly on the event horizon, would the light stand still?  And why can't light stand still? why does it always move at that really high speed? Why does Axii sign not work? Does Google treat different ports as different sites? I am really satisfied that $(x \to a) ≠(x=a)$ and if that is not right , Then all the process of $Limits$ is dividing by zero and that is a crime.  Since $(x \to a) + h = (x=a)$ , $h ≠ 0$,So Why does $f(x \to a) = f(x = a)$ ?  NOTE:I am talking about continuous function. I need to analyse data and am unsure whether or not I should use a multinomial logistic regression analysis or a binary logistic regression analysis. I have just conducted a latent class analysis and am interested in seeing if my variables can predict class membership. There are only two classes and so my response variable only has two categories; however the variables range from having 2 to 3 to 4 and are mostly nominal categorical data. Moved bin and other folders! How to get them back? Printer service not found on port 515 For services list on my Ubuntu, Printer service not found on port 515.  nmap -sT -O localhost  PORT     STATE SERVICE 23/tcp   open  telnet 139/tcp  open  netbios-ssn 445/tcp  open  microsoft-ds 631/tcp  open  ipp 9050/tcp open  tor-socks Device type: general purpose Running: Linux 3.X OS CPE: cpe:/o:linux:linux_kernel:3 OS details: Linux 3.12 - 3.19, Linux 3.8 - 3.19       There is no Printer service on port 515. How to add Printer service on port 515?     nmap -v -p 515 127.0.0.1  Starting Nmap 7.01 ( https://nmap.org ) at 2016-11-19 13:03 IRST Initiating SYN Stealth Scan at 13:03 Scanning localhost (127.0.0.1) [1 port] Completed SYN Stealth Scan at 13:03, 0.21s elapsed (1 total ports) Nmap scan report for localhost (127.0.0.1) Host is up (0.000065s latency). PORT    STATE  SERVICE 515/tcp closed printer Example where $f\circ g$ is bijective, but neither $f$ nor $g$ is bijective Can anyone come up with an explicit example of two functions $f$ and $g$ such that: $f\circ g$ is bijective, but neither $f$ nor $g$ is bijective?  I tried the following: $$f:\mathbb{R}\rightarrow \mathbb{R^{+}} $$ $$f(x)=x^{2}$$  and  $$g:\mathbb{R^{+}}\rightarrow \mathbb{R}$$ $$g(x)=\sqrt{x}$$  $f$ is not injective, and $g$ is not surjective, but $f\circ g$ is bijective  Any other examples?