i know that if i create new objects with reflection,it is very slow ,so i test it.but the result makes  me puzzled，newInstance() is faster than new(),my jdk version is java version "1.8.0_77".  public class Test {  static class B { }  public static long timeDiff(long old) {     return System.nanoTime() - old; }  public static void main(String args[]) throws Exception {      int numTrials = 10000000;     B[] bees1 = new B[numTrials];     Class&lt;B&gt; c = B.class;     long nanos;     nanos = System.nanoTime();     for (int i = 0; i &lt; numTrials; i++) {         bees1[i] = new B();     }     System.out.println("Normal instaniation took: " + TimeUnit.NANOSECONDS.toMillis(timeDiff(nanos)) + "ms");     B[] bees2 = new B[numTrials];     nanos = System.nanoTime();     for (int i = 0; i &lt; numTrials; i++) {         bees2[i] = c.newInstance();     }     System.out.println("Reflecting instantiation took:" + TimeUnit.NANOSECONDS.toMillis(timeDiff(nanos)) + "ms");  }   }  the result:   Normal instaniation took: 2363ms Reflecting instantiation took:1679ms.   so i don't know why..who can explain it ?
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 am running Ubuntu 12.04.1 LTS i686 on VirtulBox. Every time I check the updates, there's a new Linux kernel. If I install the new kernel, I have to install the Virtulbox Guest Additions again and reboot the server. I don't want to do this every week. I know I can manually uncheck the kernel packages from update manager, but is there a way to skip the kernel update automatically? I found an answer here, but it's for Ubuntu 10. Thanks. Copy files excluding x,y,z causing error in shell script I'm not well versed in shell scripting but I imagine this to be a painfully easy fix but its eluding me.  I need to copy the contents of a directory excluding a number of files. I have a command that works when I enter it into the terminal, but when its run in a shell script it fails with a syntax error or just doesn't work.   The command in question is:  cp -r path/to/!(dir1|dir2|dir3) destination   Any help would be greatly appreciated! Examples  I've recently found examples of using pairs of enclosing braces {}, with nothing in between the opening and closing braces, as arguments to commands and even to their options:  cat foo | xargs -I{} echo {}  find . -size 0 -exec rm -i {} \;  No Documentation  My problem is that I cannot find a documentation in the  that describes the usage of {} in such context as in the examples above.  I do not think it is a , because a dollar sign must precede the enclosing braces in a parameter expansion as in ${}.  It cannot be a  either, because it takes the form of {x..y[..incr]}, where x and y are not optional.  It also cannot be a  either, because {} is used as arguments.  Questions   What does a pair of enclosing braces {} even mean, in general, as an argument to any command that accepts it? Where can I find a documentation that describes the usage of {} as arguments? Notation and the name choice for meet and join (in order theory) I have two simple questions:   From where do the names  come from? I don't see any intuition between those names in context of order theory. From where does the notation come? I have to admit, I always had an impression that notation we use is somewhat backwards... just take the look at the picture at the wikipedia!    I used this notation a lot of times and I have to admit that often I have to stop for a minute and convince myself that I'm indeed using it right. I'm hoping that learning a bit about origin and context of name choice and notation will make it easier. Multiple forms in delphi Packed images used as background don't show up when reopening the file I have seen a single (1) mention of View port background images disappearing when the .blend file is saved and reopened.  However...the answers are not relative to what I am experiencing.  I go through the trouble of setting up four images (top, side, front, back) and then pack these images using External Data &gt; Pack all into .blend and then I save the .blend.  I save the file, open it back up, and the background images are all gone. Open up properties panel, look to see background images check box is unchecked, click add image, and choosing the open drop-down arrow...the data paths still show the list of images (packed into a specific folder textures).  They are still there, the data set is intact.  Why is It that I have to set this up each and every time I open the file.  It seems like earlier versions &lt;2.76B saved the images and saved the file with the background images check box checked without the need to set this up each time the file is reopened.  This is getting very frustrating due to the fact that a few of the background images mus be set up using Blender's rotate, scale and move tools to align the background image up with the model I have already fabricated.  Thanks! /boot full of kernels – what to delete? We have some Ubuntu 16.04 servers. unattended-upgrades are automatically enabled since 16.04 and /boot is a separate partition. Due to the automatic security updates, the boot partition is running out of space with new kernels. We can't reboot the systems (for availability reasons), so the machine is still using the penultimate kernel. Which kernels should I remove? All but the current, the oldest and the newest? Do you guys have some recommendations? I have also noticed that the newest kernel has the status &quot;Half Configured&quot;. This kernel would probably not work, so should I remove this one and use an older kernel? Output of dpkg -l | grep linux-image: ii  linux-image-4.4.0-21-generic --&gt; old kernel ii  linux-image-4.4.0-34-generic --&gt; current kernel ii  linux-image-4.4.0-36-generic --&gt; new kernel ii  linux-image-4.4.0-38-generic --&gt; new kernel ii  linux-image-4.4.0-42-generic --&gt; new kernel ii  linux-image-4.4.0-45-generic --&gt; new kernel ii  linux-image-4.4.0-47-generic --&gt; new kernel ii  linux-image-4.4.0-51-generic --&gt; new kernel ii  linux-image-4.4.0-53-generic --&gt; new kernel iF  linux-image-4.4.0-57-generic --&gt; new kernel Is it okay to have a multi-language deck? I want to buy a few booster pack from a local shop that only gets them in French. Is it generally acceptable to show up to a tournament with cards in different languages? How to get a normal application menu in the top- or titlebar in Gnome Was Red Shirt Security a rotating detail, like K.P, or was it a dedicated branch of Star Fleet like the M.P's are to the US Army? As I channel surfed the other day, I accidentally found an episode of Star Trek TOS, and I settled in to watch it. As always, it was a bad day to be a landing party Red Shirt Security person.    Their apparent lack of skill (training?) made me wonder: Was Red Shirt Security a rotating detail, like K.P. (Kitchen Patrol), that crew members with regular assigned duties were ordered to do when it was their turn, or was it a dedicated branch of Star Fleet like the M.P's (Military Police) are to the US Army? Comma after a coordinating conjunction preceding a parenthetical at the start of the sentence I do not know how to prove this question: $m^{\phi(n)}+n^{\phi(m)}\equiv 1 \pmod {mn}$ where $m$ and $n$ are relatively prime.  Can anyone help? How should I approach obvious proofs like these    I have been trying but couldn't find an elegant way to work these. Any help is highly appreciated ! Especially looking for a nice proof/hint for first problem I've removed the poll style answers in favour of open discussion.  I realise now this isn't the best way to have a proper discussion about this issue - sorry to anyone who commented/voted.    This is mostly a followup on this question:    As I've answered, the reason this is happening is that the root database (in the production Stack Exchange database server) is still called StackExchange.Programmers - a database name that propagates to SEDE and through it to the data dump.  The question here is what to do about it - the current situation is somewhat broken for users of the data dump.  These are the options we have:   Do nothing Update the root database name (requires downtime - so very undesirable) Update the update scripts so the SEDE database name is the new name, change will flow to the data dump export (breaks any queries using the old name) Update the export to the data dump so only it gets the new name Something else we haven't thought about   I have added all of these options as answers below - please vote on the one you most prefer, we will try to accommodate the top voted answer. Pattern matching with LIKE, SIMILAR TO or regular expressions in PostgreSQL I had to write a simple query where I go looking for people's name that start with a B or a D :   SELECT s.name  FROM spelers s  WHERE s.name LIKE 'B%' OR s.name LIKE 'D%' ORDER BY 1   I was wondering if there is a way to rewrite this to become more performant. So I can avoid or and / or like? I have seen this construction quite often:      Online ads have been around since the dawn of the Web, but only in   recent years have they become the rapturous life dream of Silicon   Valley.   What is the rule there?. When your sentence doesn't start with pronoun + verb, invert them as verb + pronoun?. I know it sounds awkward but is it possible (grammatically correct) to use something similar to:      Online ads have been around since the dawn of the Web, but only in   recent years they have become...   And in any case, does this only work with have (or has)? Maybe it works fine with 'had' but I can't think of an example right now. Should I disable swap file if I have lots of RAM or should I move it to a virtual RAM drive? Imagine I have tons of RAM. Let's say 64GB. That's a lot for even gaming PCs. Now the default location of a pagefile in Windows is on the main OS drive, be it HDD or SSD, which are faster in general, but still not as fast as RAM.  Something tells me that disabling the pagefile on the hard drive or creating a virtual RAM drive and letting the pagefile be there could make Windows move all its virtual memory to RAM, and so increase the system's performance, but I'm not very knowledgeable in that area, so that might not be true at all.  I tried both, but I couldn't analyze the results to reach a definite conclusion with my knowledge level in memory things.  Would this work? If not, why? What is the proper way to extend the Fibonacci numbers to negative numbers? I have a feeling this question is a duplicate, but it's not coming up in "Questions that may already have your answer."  We all know very well that $F(0) = 0$, $F(1) = 1$ and $F(n) = F(n - 2) + F(n - 1)$ for all $n &gt; 1$.  I'm wondering about $n &lt; 0$. My first thought was $F(-n) = -F(n)$, which is appealing from a multiplicative point of view, as it seems to preserve certain identities, like $F(n)^2 = F(n - 1) F(n + 1) - (-1)^n$.  But it doesn't quite make sense from an additive point of view, it doesn't seem to work both "forwards" and "backwards." For example, it would give us $F(-1) + F(0) = -1 \neq F(1)$.  How do we extend $F(n)$ to negative $n$ so as to maintain both the related identities and the basic defining identity? I consider the co-finite topology on $\mathbb{R}$ that is $$\{G\subset \mathbb{R}, card(\mathbb{R}\setminus G)&lt;+\infty\}\cup \{\emptyset\}$$  What are the convergent sequences in this space .  thank you How can you reduce ambient noise from servers?