I was testing the performance of two different approaches to handling streams of integers (primitives).  To my surprise, the first test case is always slower, no matter the order.  public void intStreamTest() {     final int[] ints = new int[1000];     for (int x = 0; x &lt; 1000; x++) {         ints[x] = new Random().nextInt(1000);     }     // T1     long start = System.currentTimeMillis();     for (int x = 0; x &lt;= 10000; x++) {         List&lt;Integer&gt; result =             IntStream.of(ints).boxed().collect(Collectors.toList());     }     System.out.println("T1 " + (System.currentTimeMillis() - start));     // T2     long start2 = System.currentTimeMillis();     for (int x = 0; x &lt;= 10000; x++) {         List&lt;Integer&gt; result =             IntStream.of(ints).mapToObj(Integer::valueOf).collect(Collectors.toList());     }     System.out.println("T2 " + (System.currentTimeMillis() - start2)); }   Here is an example of the output:  T1 150 T2 95   When I change the order of test cases (swap sections T2 and T1) I get:  T2 153 T1 92   Did I make a mistake? How is it possible that a second test case is always faster (approx by 60%)?
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:
Launcher Icons disappear Use LaTeX to simulate old typewriter written texts This question led to a new package:      I'm giving my students an old exam and barely remembered to change the date at the top. A colleague and I joked about how long we could reuse the same exam, and it made me wonder if I could use LaTeX to create an exam that looked like it was written in 1963 on a typewriter.  Here's what I'd like to see:   Typewriter font even in math mode. (Several ways to accomplish this; is there a "best" way?) Slight inconsistencies in the printing of each letter. I attempt this below adapting code taken from . Each word has a random vertical shift, though I'd like to see it reduced to each letter having its own vertical shift. Other typewriter-like irregularities would be great. It would be great if math-mode delimeters \left(, \right}, etc., can be created in a piece-meal fashion as they did in days of old. Fraction bars, tops of square-root symbols -- any horizontal line, really -- is made up of a series of en-dashes that don't quite match up.   Here is what I've come up with so far:  \documentclass[10pt]{article}% This is a document class providing more font size options \usepackage{graphicx} \usepackage{ifthen} \usepackage[textwidth=7.5in,textheight=9.5in]{geometry} \pagestyle{empty}  % thanks to Bruno Le Floch: https://tex.stackexchange.com/q/9331/4012 % and in his comments to https://tex.stackexchange.com/a/29458/4012 \usepackage[first=-1,last=1]{lcg}% you can play around with these values \makeatletter \newcommand{\globalrand}{\rand\global\cr@nd\cr@nd} \makeatother  \newcommand{\randomvshift}[1]{\globalrand\raisebox{\value{rand}pt}{#1}}  %%% thanks to Martin Scharrer: https://tex.stackexchange.com/q/11598/4012 \makeatletter \def\typewriter#1{%     \@typewriter#1 \@empty } \def\@typewriter#1 #2{%    \randomvshift{#1}\space    \ifx #2\@empty\else     \expandafter\@typewriter    \fi    #2% } \makeatother \begin{document}\tt  \typewriter{Math 101 Fall 1963}  \begin{enumerate} \item   \typewriter{$\frac{\texttt{d}}{\texttt{dx}}\texttt{(x)}^2$}  \item \typewriter{State the Fundamental Theorem of Calculus.}  \end{enumerate}  \end{document} How can I make schematic of this board? I want to make a schematic of this board. Can anyone tell me how? Overnight charges for brokers holding stocks? I'm trying to learn about stock markets. I eventually want to invest a small amount over a long period. Yet, I notice on a lot of broker sites that they tend to charge an overnight fee for any stocks held over night. I presume this is every night thereafter?  I just wondered because it seems like a wall when you want to let your stock price grow, and an overnight charge eats into this. or, is this only the case for "CFD" stocks? I'm confused.  Any help?  Cheers How can I find my hardware details? Is there any built-in software or terminal method allowing me to view the hardware profiles on my system? Windows equivalent of such a feature would be Device Manager. Why doesn't the frequency of light change during refraction? I have a one-dimensional array of strings in JavaScript that I'd like to turn into a comma-separated list. Is there a simple way in garden-variety JavaScript (or jQuery) to turn that into a comma-separated list? (I know how to iterate through the array and build the string myself by concatenation if that's the only way.) Send Gmail calendar invite from alternate email Disk full, du tells different. How to further investigate? I have a SCSI disk in a server (hardware Raid 1), 32G, ext3 filesytem. df tells me that the disk is 100% full. If I delete 1G this is correctly shown.  However, if I run a du -h -x / then du tells me that only 12G are used (I use -x because of some Samba mounts).  So my question is not about subtle differences between the du and df commands but about how I can find out what causes this huge difference?  I rebooted the machine for a fsck that went w/out errors. Should I run badblocks? lsof shows me no open deleted files, lost+found is empty and there is no obvious warn/err/fail statement in the messages file.  Feel free to ask for further details of the setup. Is it possible to overload the null-coalescing operator for a class in C#?    Say for example I want to return a default value if an instance is null and return the instance if it's not. The code would look like something like this:     return instance ?? new MyClass("Default");     But what if I would like to use the null-coalescing operator to also check if the MyClass.MyValue is set? Could someone please check if I'm saying something that make sense? I am trying to check the following:     If $f$ is a measurable function, then $\text{supp}(f)$ is measurable set?   Is it simply because, if we consider $E_1 = (0,\infty)$ and $E_2 = (-\infty,0)$, since they are open, they are measurable. So their union $\mathbb{R}-\{0\}$ is measurable as well. Since $f$ is measurable, then the preimage $f^{-1}(\mathbb{R}-\{0\})$ is measurable. But the preimage is just the support? How to remove the left part of a string? Urgent Sydney transit visa question How can I visualize boxes? This question led to a new package:      Some of you may know the Web Developer Toolbar for Firefox that can outline the block level elements of a page like this:  Is there a way to do something similar with TeX boxes for a complete document? How to report issues with the mobile SE application help me to find a volume of the ring shaped solid A cylindrical drill with radius 5 is used to bore a hole through the center of a sphere of radius 8. Find the volume of the ring shaped solid that remains.  Alright, my thing is that i did not understand how to set the integral Is there a way to assign a value to a variable, that value which we get in terminal by writing any command?  Example command: sensors  From that we get CPU temperature. How can I assign this value to a temp_cpu variable? Let $f(z)$ be an entire function such that $$|f(z)|&lt;\frac{1}{|\text{Im}(z)|},\qquad z\in\Bbb C-\Bbb R.$$ The question asked me to prove that $f(z)=0$. At least looking at it, it really seems to have an application of Liouville's theorem lurking around somewhere, but I haven't found it.   My thoughts first led me to think about doing this by contradiction and using Picard's little theorem. So, I've considered a strip containing the real axis (say of width $2$ for simplicity). This will imply the complement maps into the unit disk, which implies that this strip has to map almost everywhere else on the complex plane. Now, on the imaginary axis, I know that $f(z)$ will vanish as $z\to\infty$, and this seems like it might be useful. I'm sort of under the impression $f(z)$ might have an essential singularity at $\infty$, which would mean $f(1/z)$ has an essential singularity at $0$. Either way, it of course can't have a pole at $\infty$ because of $f(z)$ vanishing on the imaginary axis, and if it is a removable singularity, it must be $0$, which still gives the solution. Therefore, I think it must have something to do with $f(z)$ having an essential singularity at $\infty$.   I was hoping to combine this with the above inequality and deduce a contradiction, but I haven't thought of one yet.   Any hints or suggestions? I'm studying for a prelim. exam, so this isn't homework.  Update: So, in the spirit of searching methods using the essential singularity at $z=0$, we have $$\left|f\left(\frac{1}{z}\right)\right|\leq\frac{1}{\left|\text{Im}\left(\frac{1}{z}\right)\right|}=\frac{|z|^2}{|y|}.$$ Thus, for $|y|&gt;1$, we have $$\left|f\left(\frac{1}{z}\right)\right|&lt;|y|\left|f\left(\frac{1}{z}\right)\right|&lt;|z|^2.$$ Thus, if I can show that $|f(1/z)|$ is a polynomial, we'll know it can't have an essential singularity at the origin, concluding my proof. bisectors of an angle in a triangle intersect at a single point - proof verification Let´s consider a general triangle ABC. Let´s draw two angle bisectors from vertices A and B.  It is obvious that these two angle bisectors intersect at a single point X. Since X lies on the angle bisector from A its distance from side b is the same as its distance from side c. As X also lies on the angle bisector from B, its distance from side c is the same as its distance from side a.  By transitivity the distance from the point X to the side b has to be the same as the distance from X to the side a. Therefore the angle bisector from C (which is the set of points equidistant from b and a) has to go through X.  It seems as a very simple argument. Is it correct? Possible Duplicate:           What book would you recommend for an undergraduate wanting to learn the basics of topology? I've come across several books that claim to give an introduction to the subject, but I wasn't sure which one(s) to pick.  Here are some of the books I came across:   Introduction to Topology - Bert Mendelson Basic Topology - M.A. Armstrong First Concepts of Topology - William G. Chinn Topology Without Tears - Sidney A. Morris Topology - James Munkres   They don't go over the exact same topics, some are more in-depth than others, some seem to target slightly different audiences etc. What would be right for me (not necessarily from that list)? To give some more background, I want to learn topology because I feel it will be somewhat helpful in the field of Computer Vision.