To compare how short circuit evaluation logical operators, for example &amp;&amp;, perform compared to bitwise evaluation logical operators, i.e. &amp;, I wrote this example and ran it:  package examples1;  import java.util.Scanner;  public class ShortCircuitOperatorsVSBitwiseOperators {     public static void main(String[] args) {         Scanner scanner = new Scanner(System.in);         System.out.print("Enter A: "); boolean a = scanner.nextBoolean();         System.out.print("Enter B: "); boolean b = scanner.nextBoolean();         long startTimeShortCircuited = System.currentTimeMillis();         boolean resultShortCircuited = true;         for(long i = 0; i &lt; 10000000000L; i++) {             resultShortCircuited = a &amp;&amp; b;         }         long endTimeShortCircuited = System.currentTimeMillis();         System.out.println(resultShortCircuited + " in " + (endTimeShortCircuited - startTimeShortCircuited) + " milliseconds, short-circuited");          long startTimeBitwise = System.currentTimeMillis();         boolean resultBitwise = true;         for(long i = 0; i &lt; 10000000000L; i++) {             resultBitwise = a &amp; b;         }         long endTimeBitwise = System.currentTimeMillis();         System.out.println(resultBitwise + " in " + (endTimeBitwise - startTimeBitwise) + " milliseconds, bitwise");         scanner.close();     } }   An example run shows the following:  java examples1/ShortCircuitOperatorsVSBitwiseOperators Enter A: false Enter B: true false in 4829 milliseconds, short-circuited false in 3276 milliseconds, bitwise   This doesn't make sense. I would expect the short circuit evaluation to be faster since it doesn't evaluate the right side of the &amp;&amp; in this case if the left side was false. What is the reason for the counter-intuitive results?
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:
Is sun revolving around certain mass in space with reference to some other galaxy? I want to change only the color (not font size, etc.) of all headings in my documents (\section, \subsection, \subsubsection, ...). I want to keep all other settings fixed.   Is there a way to do this? Is it possible to place windows with keyboard shortcuts in Gnome-Shell? With Compiz in Unity, I could press Ctrl+Alt+6 to place a window on the right-half of the screen, Ctrl+Alt+4 to place it on the left half, Ctrl+Alt+7 to place it in the top left quarter of the screen, and so on. Is there something similar in Gnome-Shell? Could there be a bit of reputation leakage between the sites, please? Did all Headmasters get a portrait in Hogwarts? some \newcommand instructions not working How to enforce sender address to be "logged-in-user@example.org" in Postfix? I have set up a Postfix server with SMTP AUTH (STARTTLS on port 587). All my users are in the domain "example.org". I want to enforce the sender address to be "logged-in-user@example.org".  I learned that this can be achieved with the main.cf options  smtpd_sender_restrictions = reject_sender_login_mismatch, ... smtpd_sender_login_maps = hash:/etc/postfix/smtpd_sender_login_maps   with a login_maps file like:  a@example.org a b@example.org b c@example.org c ...   (see also ), but this would mean I'll have to edit the login_maps file every time I have a new user. I don't need such a flexible mapping: It should always be "logged-in-user@example.org". Is there an easier option? We all use mathematical induction to prove results, but is there a proof of mathematical induction itself? I just realized something interesting. At schools and universities you get taught mathematical induction. Usually you jump right into using it to prove something like   $$1+2+3+\cdots+n = \frac{n(n+1)}{2}$$  However.  I just realized that at no point is mathematical induction proved itself? What's the mathematical induction's proof? Is mathematical induction proved using mathematical induction itself? (That would be mind blowing.) Follow a question I've come across a few interesting questions over the last few months on Stack Overflow. They're not necessarily questions I need an answer to, but the questions are nonetheless very interesting, and now I want to know what the answers are.  I don't want to add this question to my favourites because I have my really handy posts in there.   Ideally I would like to have another kind of shortlist to which I can add these posts. I would get notifications just as if it were my own post, without having these as favourites.  What do you think of that? It would be available only for questions, and you would receive notifications just like the author, for new answers and comments on the question (not comments on the answers).  You could browse the posts you're following, as well as stop following them.   The thing is sometimes I come across a semi interesting question and upvote and maybe even comment, but I never hear about it again, because sometimes it's just not interesting enough to remember.  Like I said in the comments, I don't feel like the favourite list is really for this. I want in-your-face red dot notifications for new answers on brand new interesting questions I find. The favourites is for that post with an answer that you know you'll need again. What's the difference between running a program as a daemon and forking it into background with '&'? What are the practical differences from a sysadmin point of view when deploying services on a unix based system? An insurance company supposes that the number of accidents that each of its policyholders will have this year is Poisson distributed, with a mean depending on the policyholder: the Poisson mean Λ of a randomly chosen person has a Gamma distribution with the Γ(2, 1)-density function fΛ(λ) = λe−λ (λ > 0). Find the expected value of Λ for a policyholder having x accidents this year (x = 0, 1, 2, . . .).  I am not sure how to incorporate the gamma parameters. So far I have found P(X = n|Λ = λ) = Poisson(λ) and fΛ(λ)= Exp(λ) so by integrating P(X = n|Λ = λ)fΛ(λ) then letting the integral of Gamma (n + 2, 2) equate to 1, I have worked out P(X = n) = (n + 1)/2^(n+2). How do you find the expected value of Λ from that? I have seen that a Gamma-Poison mix has E(X) = αβ which would give 2 but I have tried integrating fΛ(λ) and can't seem to get 2. Suppose I have a node in the shape of a circle. How can I make its border thicker?   \node[circle, draw=blue!80, inner sep=0pt, minimum size=12pt] (1) at (0,0) {1}; How do you tell if caps lock is on using JavaScript?  One caveat though: I did google it and the best solution I could find was to attach an onkeypress event to every input, then check each time if the letter pressed was uppercase, and if it was, then check if shift was also held down. If it wasn't, therefore caps lock must be on. This feels really dirty and just... wasteful - surely there's a better way than this? How do you copy the contents of an array to a std::vector in C++ without looping? How does Linux handle multiple consecutive path separators (/home////username///file)? I'm working on a python script that passes file locations to an scp subprocess. That's all fine, but I'm in a situation where I may end up concatenating a path with a filename such that there's a double '/ in the path. I know that bash doesn't care if you have multiple file separators, but I'm wondering how exactly that is rectified. Is it bash that strips extra /s or does it really not matter ever?  I ask because it will save me several lines of code to check for extra /s while concatenating. I know it's not a big deal, but I'm curious as well. I have a bash script that has the line cd //usr (instead of cd /usr), which seems to imply there might be a significance to using multiple /s in a path How to make a bootable ISO image from a bootable DVD? Kant introduces the notion of the noumenon in his critical philosophy; he also later demonstrates in his system that solipsism isn't possible.   Is the introduction of the noumenon essential to this demonstration, and thus justifies it's introduction? Reference — What does this symbol mean in PHP? How does the T-1000 see? In Terminator 2: Judgement Day, how does the T-1000 sense things? It's made of mimetic poly alloy; however, does it have a retinal scan camera like the T-X or T-800, or is just molecules that allow it to see what it does? In other words: let's say it is made out of nanobots. Would a group of these nanobots provide the capability of sight? Kind of like humans with cells that  make up the brain? I have always wondered whether James Cameron explained this on a special edition or if the topic was left up for insight from Terminator fans. From what I get from the whole mimetic poly alloy and some of the extra scenes, it seems to feel its way out to get information. Of course, it's very much not blind! Thoughts? Is there a pronoun I can use as a gender-neutral pronoun when referring back to a singular noun phrase?  Each student should save his questions until the end. Each student should save her questions until the end.