I have a very simple program package t; public class T {      public static void main(String[] args) {         for (int i =0; i&lt;10; i++) {             java.util.List&lt;Character&gt; l = java.util.Arrays.asList('1', '2', 'a', 'b', '3', '4', 'p');             java.time.Instant then = java.time.Instant.now();             java.util.List&lt;Character&gt; numbers1 = l.stream().filter(Character::isDigit).collect(java.util.stream.Collectors.toList());             long streamTime = java.time.Duration.between(then, java.time.Instant.now()).toNanos();             then = java.time.Instant.now();             java.util.List&lt;Character&gt; numbers = new java.util.ArrayList&lt;&gt;();             for (Character c : l) {                 if (Character.isDigit(c)) {                     numbers.add(c);                 }             }             long forLoopTime = java.time.Duration.between(then, java.time.Instant.now()).toNanos();             System.out.println(numbers + &quot; For Time taken &quot; + forLoopTime + &quot; Stream Time &quot; + streamTime);         }     } }  When executed in Java 8 following is the o/p java t/T [1, 2, 3, 4] For Time taken 0 Stream Time 54000000 [1, 2, 3, 4] For Time taken 0 Stream Time 0 [1, 2, 3, 4] For Time taken 0 Stream Time 0 [1, 2, 3, 4] For Time taken 0 Stream Time 0 [1, 2, 3, 4] For Time taken 0 Stream Time 0 [1, 2, 3, 4] For Time taken 0 Stream Time 0 [1, 2, 3, 4] For Time taken 1000000 Stream Time 0 [1, 2, 3, 4] For Time taken 0 Stream Time 0 [1, 2, 3, 4] For Time taken 0 Stream Time 0 [1, 2, 3, 4] For Time taken 0 Stream Time 0  Same executed in java 16 java t/T.java [1, 2, 3, 4] For Time taken 37000 Stream Time 701000 [1, 2, 3, 4] For Time taken 6000 Stream Time 31000 [1, 2, 3, 4] For Time taken 6000 Stream Time 12000 [1, 2, 3, 4] For Time taken 5000 Stream Time 11000 [1, 2, 3, 4] For Time taken 5000 Stream Time 12000 [1, 2, 3, 4] For Time taken 7000 Stream Time 19000 [1, 2, 3, 4] For Time taken 6000 Stream Time 18000 [1, 2, 3, 4] For Time taken 7000 Stream Time 18000 [1, 2, 3, 4] For Time taken 7000 Stream Time 14000 [1, 2, 3, 4] For Time taken 6000 Stream Time 20000  When executed in java 11 java t/T.java [1, 2, 3, 4] For Time taken 40000 Stream Time 461000 [1, 2, 3, 4] For Time taken 7000 Stream Time 39000 [1, 2, 3, 4] For Time taken 5000 Stream Time 17000 [1, 2, 3, 4] For Time taken 10000 Stream Time 20000 [1, 2, 3, 4] For Time taken 9000 Stream Time 33000 [1, 2, 3, 4] For Time taken 8000 Stream Time 22000 [1, 2, 3, 4] For Time taken 8000 Stream Time 36000 [1, 2, 3, 4] For Time taken 6000 Stream Time 17000 [1, 2, 3, 4] For Time taken 6000 Stream Time 14000 [1, 2, 3, 4] For Time taken 5000 Stream Time 22000  This indicates that no matter which version of JDK we use streams are slower than basic for loop. Is my understanding correct? I was under the impression that JDK 8 it may have been slower but not in higher versions of JDK.
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:
Prove that $d(n)\leq 2\sqrt{n}$ In Waclaw Sierpinski's book Elementary Theory of Numbers on page 168 there is the following exercise:  "Exercises. 1. Prove that for natural numbers $n$ we have $d(n) \leq 2\sqrt{n}$," where $d(n)$ is the number of divisors of n.  As a hint right below is given: "The proof follows from the fact that of two complementary divisors of a natural number $n$ one is always not greater than $\sqrt{n}$.  I understand the hint but I don't know how it can be used to prove $d(n)\leq 2\sqrt{n}$.  Complementary divisors are pairs of divisors that when multiplied gives the number that is to be divided. For example the number $120$ has the complementary divisors: \begin{align*} &amp; 1, 120 \\ &amp; 2, 60 \\ &amp; 3, 40 \\ &amp; 4, 30 \\ &amp; 5, 24 \\ &amp; 6, 20 \\ &amp; 8, 15 \\ &amp; 10, 12 \\ \end{align*} How do you prove that $d(n) \leq 2\sqrt{n}$? On every boot up I get this:    For about 10 seconds (or more) before the "normal" Ubuntu Gnome loading screen and the login screen comes up.  I've read some questions and a bug report about this already, but this problem was dismissed as a minor inconvenience or there were no real solutions (that worked for me). For me, this problem leads to an unacceptable slow boot compared to Ubuntu (Unity) or Windows.  Does anybody know how to fix this or is this a "feature" of Ubuntu Gnome and not a bug? Adding/updating field to polygon feature class that lists bordering (neighbor) polygons? I have a dataset of zipcodes.  I want to add a new field "NEIGHBORS" that includes bordering polygons in a comma delimited manner such as attached image: I think this is just something I've grown used to but can't remember any proof.  When differentiating and integrating with trigonometric functions, we require angles to be taken in radians. Why does it work then and only then? Just like if we have any quadratic equation which has complex roots, then we are not able to factorize it easily. So we apply quadratic formula and get the roots.  Similarly if we have a cubic equation which has two complex roots (which we know conjugate of each other) and one fractional root, then we are not able to find its first root by hit &amp; trial.  So my question is like quadratic formula, is there exist any thing like cubic formula which help in solving cubic equations?  For example, I have an equation $$2x^3+9x^2+9x-7=0\tag{1}$$ and I have to find its solution which I am not able to find because it has no integral solution. Its solutions are $\dfrac {1}{2}$, $\dfrac{-5\pm \sqrt{3}i}{2} $, I know these solutions because this equation is generated by myself.  So how can I solve equations like these?  Also while typing this question, I thought about the derivation of quadratic formula, which is derived by completing the square method.  So I tried to apply ‘completing the cube’ method on the general equation $ax^3+bx^2+cx+d=0$ but it didn't help.  So please help me in finding a cubic formula or to solve the equations like given in example by an alternative method. Adding objects algorithm in Objective-C "The ones" or "those"? I recently corrected  &quot;ghettos, such as the ones found...&quot; to &quot;ghettos, such as those found...&quot;  Was I correct, or are both versions right? Binomial Distribution Problem - Airline Overbooking Why Windows sets new created file's "created time" property to old time? R stem and leaf values Who owns the copyright to S[OFU] content? What with  today, possibly this is a good time to ask: who actually owns the copyright to questions, answers and comments submitted to StackOverflow and relatives?  Over in , we have the OP reaching the conclusion that SO owns the copyright and is licensing it under CC-Attribution-Sharealike, with no apparent confirmation or denial from staff, and in  we have a moderator asserting that Jeff owns the copyright to SO content.  As I note in a comment on the latter, though (which was met with deafening silence), I'm failing to find any evidence that this is the case.  I've looked for any kind of terms of service I may have agreed to indicating that I am signing over ownership of my words when I hit submit, and I can't find one.  Certainly the fact that I'm agreeing to CC-Attribution-Sharealike licensing is clear enough, but it seems to me as if I am retaining copyright while agreeing to those licensing terms, and S[OFU] is using what I have written under that license.  What's the deal?  Did I forget about something that I agreed to in the signup process (and if so, why can't I find it afterward)?  Do the owners and administrators of S[OFU] believe that they own copyright to the UGC?  Just what is going on here?  Edit as to why this matters (from answer comment thread): If I retain copyright, I can also choose to license the original content to other parties under other terms (such as using a zero-requirements license, using an attribution-required license without sharealike, etc). If SO has the copyright, I can't. Proof that the One-Dimensional Simple Harmonic Oscillator is Non-Degenerate? The standard treatment of the one-dimensional  (SHO) using the raising and lowering operators arrives at the countable basis of eigenstates $\{\vert n \rangle\}_{n = 0}^{\infty}$ each with corresponding eigenvalue $E_n = \omega \left(n + \frac{1}{2}\right)$. Refer to this construction as the abstract solution.  How does the abstract solution also prove uniqueness? Why is there only one unique sequence of countable eigenstates? In particular, can one prove the state $\vert 0\rangle$ is the unique ground state without resorting to coordinate representation? (It would then follow that the set $\{\vert n \rangle\}_{n = 0}^{\infty}$ is also unique.)  The uniqueness condition is obvious if one solves the problem in coordinate representation since then one works in the realm of differential equations where uniqueness theorems abound. Most textbooks ignore this detail (especially since they often solve the problem both in coordinate representation and abstractly), however I have found two exceptions:   Shankar appeals to a theorem which proves one-dimensional systems are non-degenerate, however this is unsatisfactory for two reasons:   Not every one-dimensional system is non-degenerate, however a general result can be proven for a large class of potentials (the SHO potential is in such a class). The proof requires a departure from the abstract solution since it classifies the potentials according to their functional properties.  Griffiths addresses this concern in a footnote stating that the equation $a \vert 0\rangle = 0$ uniquely determines the state $\vert 0\rangle$. Perhaps this follows from the abstract solution, however I do not see how. FAQ: Migrations What are the rules on migrations:   Migrations in general Migrations to public betas Migrations to private betas What is the correct output of cat /etc/apt/sources.list? Subset data frame based on number of rows per group This is a  about DNS/Hostnames resolution to IPs/Ports   Example 1  I'm running a web server on port 80 and another on port 87. I would like to use DNS so that www.example.com goes to port 87. How can I accomplish this using DNS only?  Example 2  I'm running a service on my server on a non-standard port. How can I get clients to connect to this non-standard port automatically? Can I use DNS? Is there some application specific support where DNS could indicate the IP and Port?   Example 3  Do some application protocols specifically support hostname awareness, and allow special actions to be taken based on this information? Are there other questions on Server Fault that cover some of these?  Commandeering: This question was originally asking about running IIS and Apache on the same server, but the same concepts can be applied to any server software receiving connections from clients. The Answers below describe the technical problems and solutions of using DNS and application protocol support to assign a port number for a client to connect. Math notation in LaTeX? How can I write e^(3j) in LaTeX?  I have tried many syntax, like $e^(3j)$ or $e^*{3j}$  Any help will be very well received. Do you have tips or a guide how to install Ubuntu in Microsoft Virtual PC?  I have found some (older) information, but I wonder if this is still valid. And it looks very "unfriendly". If an object is large enough and slow enough is there a point that we can say we know its position and momentum? I'm colorizing the header of a table formatted with column -ts $'\t'  Works well without color codes, but when I add color codes to the first line column doesn't properly align the output.  Without colored output it works as expected: printf "1\t2\t3\nasdasdasdasdasdasdasd\tqwe\tqweqwe\n" | column -ts $'\t'  But when adding color on the first line column doesn't align the text of the colored row: printf "\e[7m1\t2\t3\e[0m\nasdasdasdasdasdasdasd\tqwe\tqweqwe\n" | column -ts $'\t'  Observed this behaviour both on Ubuntu Linux and Mac OS X.