I set out to test the following claim in the Javadoc for Collections::addAll:     The behavior of this convenience method is identical to that of c.addAll(Arrays.asList(elements)), but this method is likely to run significantly faster under most implementations.   I've used the following code to test the runtime of addAll for ArrayList and LinkedList (as well as Collections on the current collection):  public static void main(String[] args) {   final String LIST_STRING = "ArrayList::addAll";   Tracker arrTracker = new Tracker(LIST_STRING);   Tracker colTracker = new Tracker("Collections::addAll");   final String GREEN = "\u001B[32m";   final String END_GREEN = "\u001B[0m";   TimeMeasurer elapsed = new TimeMeasurer();   Integer[] ints = new Integer[2_000_000];   for(int i = 0; i &lt; ints.length; i++)   {     ints[i] = Integer.valueOf((int) (Math.random()*50_001)-25_000);   }   System.out.println("Array filled! "+elapsed);   List&lt;Integer&gt; collection = new ArrayList&lt;&gt;(List.of(1, 2, 3));   List&lt;Integer&gt; list = new ArrayList&lt;&gt;(List.of(1, 2, 3));    System.out.println("Created initial lists. "+elapsed);   for(int i = 0; i &lt; 4; ++i)     Collections.addAll(collection,ints);   System.out.println(GREEN+"Collections::addAll. "+elapsed+END_GREEN);   collection.clear();   collection = null;   for(int i = 0; i &lt; 5; i++)     System.gc();   System.out.println("Garbage collected. "+elapsed);   for(int i = 0; i &lt; 4; ++i)     list.addAll(Arrays.asList(ints));   System.out.println(GREEN+LIST_STRING+". "+elapsed+END_GREEN);   list.clear();   list = null;   for(int i = 0; i &lt; 5; i++)     System.gc();   System.out.println("Garbage collected. "+elapsed);    //redoing   for(int iter = 0; iter &lt; 100; iter++)   {     System.out.println();     collection = new ArrayList&lt;&gt;(List.of(1, 2, 3));     list = new ArrayList&lt;&gt;(List.of(1, 2, 3));     System.out.println("Recreated initial lists. "+elapsed);     for(int i = 0; i &lt; 4; ++i)       Collections.addAll(collection,ints);     System.out.println(GREEN+"Collections::addAll. "+colTracker.on(elapsed)+END_GREEN);     collection.clear();     collection = null;     for(int i = 0; i &lt; 5; i++)       System.gc();     System.out.println("Garbage collected. "+elapsed);     for(int i = 0; i &lt; 4; ++i)       list.addAll(Arrays.asList(ints));     System.out.println(GREEN+LIST_STRING+". "+arrTracker.on(elapsed)+END_GREEN);     list.clear();     list = null;     for(int i = 0; i &lt; 5; i++)       System.gc();     System.out.println("Garbage collected. "+elapsed);   }   System.out.println();   System.out.println(colTracker.average());   System.out.println(arrTracker.average()); }   I ignore the first run for the purposes of warming up the JVM, and change = new ArrayList&lt;&gt;(...) to = new LinkedList(...) when testing for LinkedList runtimes. Each addition consists of 2 million random integers, repeated 4 times, for a total of 8 million integers being appended. Here are the final outputs from the time testing code for LinkedList:     Average milliseconds per run for Collections::addAll: 3586.153   Average milliseconds per run for LinkedList::addAll: 6900.910     Here are the final outputs from the time testing code for ArrayList:     Average milliseconds per run for Collections::addAll: 354.337   Average milliseconds per run for ArrayList::addAll: 272.990     So, here's what I'd like to know:   Controlling for List type, why is LinkedList::addAll so much slower than Collections::addAll? Controlling for List type, why is ArrayList::addAll faster than Collections::addAll?
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:
I'm splitting a string by three different characters but I want the output to include the characters I split by. Is there any easy way to do this? Let $U\subset\mathbb R^3$ be an open set, and $f:U\to \mathbb R$ be a smooth function. Suppose that the level set $S=f^{-1}(\{0\})$ is non-empty, and that at each $p\in S,$ the gradient $\overrightarrow \nabla f(p)$ is not the zero vector. Then $S$ is a smooth two-dimensional surface in $U$, and $p\mapsto \overrightarrow \eta(p)=\frac{1}{||\overrightarrow \nabla f(p)||}\overrightarrow \nabla f(p)$ defines a smooth unit-length normal vector field along $S$. At each $x\in U,$ write $H(f)_{(x)}$ for the $3\times 3$ Hessian matrix specified by $$(H(f)_{(x)})_{ij}=\frac{\partial^2f}{\partial x_i\partial x_j}(x).$$   Show that, at each $p\in S$, the second fundamental form $II_p: T_p(s)\times T_p(s)\to \mathbb R$ is the symmetric bilinear map    $$II_p(\overrightarrow v,\overrightarrow w)=\frac{-1}{||\overrightarrow \nabla f(p)||}\overrightarrow v\cdot H(f)_{(p)}\overrightarrow w,$$for all $\overrightarrow v ,\overrightarrow w \in T_p(s)$.       (Here, we view the tagent space $T_p(S)$ as the two-dimensional subspace $(span\{ {\overrightarrow \eta(p)}\})^{\bot}$ of $\mathbb R^3$.      Edit: Actually my question is why the second fundamental form under the usual definition can be written in this way.      Definition: The quadratic form $II_p$, defined in $T_p(S)$ by $II_p(v)=-&lt;d  N_p(v),v&gt;$ is called the second fundamental form of $S$ at $p$, where $dN_p:T_p(S)\to T_p(S)$ is the differential of the Gauss map.   Hopefully, I express this problem explicitly. I was just wondering how to prove this statement.   I took a diffrential geometry class last semester, and when I organized my notes this morning, I found this statement, but there was no proof...  Looking forward to an understandable explaination. Thanks in advance.     Edit 2:Furthermore, show that, at each point $p\in S$, the expression   $$\phi_p(z)=det\pmatrix{-H(f)_{(p)}-zI_{3\times 3} &amp; \overrightarrow \nabla f(p)\\\ \pm \overrightarrow \nabla f(p)&amp; 0}$$   (the underlying matrix here is $4\times 4$) defines a second-degree polynomial whose roots $\lambda_1$ and $\lambda_2$ are $||\overrightarrow \nabla f(p)||k_1$ and $||\overrightarrow \nabla f(p)||k_2$, where $k_1$ and $k_2$ are the principal curvatures of $S$ at $p$.      Also, if a non-zero vector $\pmatrix {\overrightarrow v \\c}$ lies in the kernel of the $4\times 4$ matrix $$\pmatrix{-H(f)_{(p)}-\lambda_jI_{3\times 3} &amp; \overrightarrow \nabla f(p)\\\ \pm \overrightarrow \nabla f(p)&amp; 0},$$   then $\vec v$ is a non-zero element of $T_p(S)$ and lies in the "principal direction" corresponding to $K_j$. I am new to TeX/LaTeX. How do I install TeX on Windows (7)? It seems that there are many different implementations, so which one is best for my OS? Is "princessship" a real word? Are there any other words which have the same letter 3 times consecutively? Constructor not defined error in test code I think this was more of a fantasy series, though it was more subtle than The Lord of the Rings IIRC. Set in modern times - though there was some alternate realm thing that was less modern I think.   I read it about ten years ago, I think, and there were a number of books at that time. My brother and I stopped reading it shortly after the main character summoned a small demon somehow who was a bad influence... I think.  It involved a boy who somehow was at some kind of training school/academy. Unsure where it was located, but it needed a classic portal to get to it I think. I clearly remember some scene involving a car driving at specific speeds to get past some barriers. There may have been something about how the school was (slowly) moving or the wards were shrinking... unsure. I don't think it was only magic based, but that was some element of it. The boy had some kind of strange power that made him an incredible fighter, but he wasn't sure how (at least from what I remember). The recordings of him training just showed a white flash I think. I remember some scene in an elevator going down to the training floor where he went to a level below some adult with him.  There was something else about him joining a group that had twelve members, one for each month, whose powers grew and lessened based on how close the date was to "their" month.  Oh, and there was something about him looking for his mother I think? Perhaps in another "realm"?   Any help is appreciated! Why we won't extract heat from air temperature? Suppose I look at a parallel plate capacitor in its rest frame and calculate the electrostatic energy, $E$.  Next, I look at the same capacitor in a primed frame boosted in the direction perpendicular to the plane of the plates. In this frame, the $E$-field is the same strength, there is no magnetic field, and the volume over which the $E$-field extends is less by a factor $1/\gamma$. This suggests $E' = \frac{1}{\gamma} E$, but relativity states that energy transforms as $E' = \gamma E$.   Where is the missing energy? Which is better to do client side or server side validation?  In our situation we are using    jQuery and MVC.   JSON data to pass between our View and Controller.     A lot of the validation I do is validating data as users enter it. For example I use the the keypress event to prevent letters in a text box, set a max number of characters and that a number is with in a range.   I guess the better question would be, Are there any benefits to doing server side validation over client side?    Awesome answers everyone. The website that we have is password protected and for a small user base(&lt;50). If they are not running JavaScript we will send ninjas. But if we were designing a site for everyone one I'd agree to do validation on both sides. Stance on repost question instead of editing to invalidate answers? Regarding , made by me, and general questions in this matter. I did receive decent answers on the question that was asked, but it wasn't asked clear enough by me I now see. I do not want to invalidate the answers by completely restructuring the question. Should one post a new question ignoring the other? or Should one refer to their old post and writing a short &quot;because x I reposted this...&quot;? What does Minecraft's scary music mean? Apparently it means there is a dungeon around but I can never find any?  If it does mean dungeons how far away will it trigger? For what values of $n > 1$ and a is $x^n - a$ irreducible in $\mathbb Q[x]$? $$x^n-a$$  So $n$ is any integer greater than 1, and $a$ is any integer.  $a$ being any integer is where I am running into trouble.  I have already shown and worked out a proof for this being irreducible when a is prime.  Now I am just working through examples, trying to figure out a pattern.  The exercise is asking for application of Eisenstein's Criterion only, so I am assuming that the value of n should have no effect on the irreducibility. Can you re-equip equipment to the same creature? Change the location of .bashrc Is it possible to change the location of .bashrc from /home/orhanc/.bashrc to some other directory? Where is my Minecraft folder on Windows? I don't have a minecraft folder. I've looked through forums and videos, followed all the steps. I just don't have one. I have windows 7, and I have "view hidden files" turned on. I have look in the roaming folder of my app data folder, with hidden files turned on. I want to find my folder so I can install a mod, could someone please tell me why my folder isn't showing up? How do I stop Windows 10 from updating my graphics driver? Every time Windows 10 runs updates (which I see no way to control), it updates my graphics driver.  I like the old one because it is faster.  So, I have to reinstall it.  This is getting to be a pain.  Is there any way to stop Windows 10 from updating it again? At what point is a creature's toughness calculated? If I have  where I can sacrifice a creature and put X 1/1 token creatures onto the battlefield, where X is the sacrificed creature's toughness.  If I have a creature that is 4/4 and cast  to give it +3/+3 then sacrifice it? Do I get 4 tokens or 7?  Also what if my 4/4 creature was dealt 2 combat damage before I sacrificed it? Do I get 2 or 4 creatures?  Finally, what about counters? If my 4/4 had a +1/+1 do I get 4 or 5 tokens? I want to know which sentence is correct. If i say     Guess, what it is?   or     Guess, what is it?   which one is correct? What are all the marriages and child relationships following the final chapter? In the last chapter of Naruto, some characters got married, and some of them had kids. What is the entire husband-wife-kids set? If Z is a square integrable random variable such that $E[Z]&gt;0$, then prove that  $$P(Z\geq k) \geq \frac{(E(Z)-k)^2}{E(Z^2)} \forall k \in [0,E(Z)]. $$  This is a homework question and I don't even understand why the inequality is reversed comparing to Markov/Chebychev inequality. Should Cauchy-Schwartz inequality be used? If yes, then how to begin? Thanks a ton!