while working on performance sensitive code I discovered that HashSet should offer constant time performance for its add, remove, contains and size methods as long as the hash-function returns unique hashes for the elements in the set ().  When executing the following code, I discovered that this constant time performance for the add method does not hold true. The following code should round in roughly double the time compared with the runtime of executing it with numberOfELements = 10.000.000. But it needs roughly 3-4 times as long.  HashSet&lt;Integer&gt; myHashSet; int numberOfElements;  //Warm-up code numberOfElements = 10000000; //10 Mio Elements myHashSet = new HashSet(540000000); //Create HashSet with large enough initial capacity to avoid resize operations for (int i = 0; i &lt; numberOfElements; i++){    myHashSet.add(i); //Add random element }  //First benchmark numberOfElements = 5000000; //5 Mio Elements myHashSet.clear(); //Clear HashSet long startTime = System.nanoTime(); //Save start time for (int i = 0; i &lt; numberOfElements; i++){    myHashSet.add(i); //Add elements } System.out.print("Set filled with " + myJournalPoC.SFA_Journal.size() + " records in "); System.out.println((System.nanoTime() - startTime)/1000000000 + "s");  // Second benchmark numberOfElements = 10000000; //10 Mio Elements myHashSet.clear(); //Clear HashSet long startTime = System.nanoTime(); //Save start time for (int i = 0; i &lt; numberOfElements; i++){    myHashSet.add(i); //Add elements } System.out.print("Set filled with " + myJournalPoC.SFA_Journal.size() + " records in "); System.out.println((System.nanoTime() - startTime)/1000000000 + "s");  // Third benchmark numberOfElements = 20000000; //20 Mio Elements myHashSet.clear(); //Clear HashSet long startTime = System.nanoTime(); //Save start time for (int i = 0; i &lt; numberOfElements; i++){    myHashSet.add(i); //Add elements } System.out.print("Set filled with " + myJournalPoC.SFA_Journal.size() + " records in "); System.out.println((System.nanoTime() - startTime)/1000000000 + "s");  // Third benchmark numberOfElements = 40000000; //40 Mio Elements myHashSet.clear(); //Clear HashSet long startTime = System.nanoTime(); //Save start time for (int i = 0; i &lt; numberOfElements; i++){    myHashSet.add(i); //Add elements } System.out.print("Set filled with " + myJournalPoC.SFA_Journal.size() + " records in "); System.out.println((System.nanoTime() - startTime)/1000000000 + "s");   I'd really appreciate to know the root cause for this behavior.  EDIT: I added the code to measure performance in the example above.
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:
touchdown held down libgdx The characteristic and minimal polynomial of a companion matrix Alternate moves, first one to roll a 6 wins: what's the probability of winning? "Users" folder shared with everyone Today I found something strange on my newly installed Windows 7 OS - my "users" folder C:\Users was shared and "Everyone" had full access... I disabled that and now it seems fine, however I'm a bit scared actually, I'd like to know what caused that and if my system is compromised. Can I make a custom node from a group and have that available in other projects? I've found some neat combinations of nodes to create certain effects, so I'd like to make them a group and then have that node available on my list of available nodes, even when I reload the startup file. How would I do that? How to align checkboxes and their labels consistently cross-browsers There's a department at my university where the head of department is routinely put as author on papers he didn't contribute to, and where researchers from overseas who had no input (but who provide funding to the department) are put on papers.    As a pragmatic matter, how should a PhD student respond when they are told to put three names on a paper, when those people didn't contribute?  Assume that refusing to put the co-authors on is not an option, because:   There will be bad consequences if they do not, and  This practice is routinely done at a high level, and there is nobody at the university to complain to about it.   This is not a duplicate of , because its answer assumes that it is practical for the student to refuse. How soon can I re-apply for a UK visa after getting a refusal? TexStudio IEEEtrantools package issue. User .cwl file? I am using TexStudio 2.9.4 on Windows 7. There is a problem that has been raised here at least once. It is that TexStudio flags unrecognised command  to  \begin{IEEEeqnarray}{rCl} and then within the environment flags expressions like \mathrm as being used outside the math environment. The fix (on Windows) is to manually edit the file C:\Users\USER\AppData\Roaming\texstudio\IEEEtrantools.cwl adding:  \begin{IEEEeqnarray}{cols}#\math,array \end{IEEEeqnarray} \begin{IEEEeqnarray*}{cols}#\math,array \end{IEEEeqnarray*}   in place of the \IEEEeqnarray entry there.   This works but is there a separate file that I could add (eg myfixes.cwl) which TexStudio would read? Burying the fix in a big autogenerated file is not ideal.  BTW is there any documentation on the format of .cwl files? How can I prevent my Wi-Fi connection from glitching? Calculating $\int_{|z|=2}\frac{e^{1/z^2}}{1-z}dz$ Find the value of $\displaystyle\int_{|z|=2}\frac{e^{1/z^2}}{1-z}dz$   The first idea I had was to apply Cauchy's integral formula. But can this be done? $e^{1/z^2}$ is not holomorphic on the interior of $|z|=2$. Still, if we would apply this we would obtain:  $\displaystyle\int_{|z|=2}\frac{e^{1/z^2}}{1-z}dz=-2\pi ie$.  Another way I think, is to apply the residue theorem. For $1-z$ has a simple zero at $z=1$ and $e^{1/1^2}\neq 0$, then the residue of $e^{1/z^2}/(1-z)$ at $z=0$ is $-e$. Again we obtain $2\pi iRes(g;0)=-2\pi ie$, where $g=\frac{e^{1/z^2}}{1-z}$.  But again, it seems to me this is not right because $g$ has two singularities, at $z=1$ and $z=0$. What we might do about $z=0$? The answer is not $-2\pi i e$? I gave a scammer my telephone number, address, and name. How bad is it? Updated question because old one was embarassing: I saw a spam email from "PayPal" and I didn't realize that it was a phishing attempt. I gave the phishing site my name, telephone number, and email. What could he do with them?  Old question: Well, I saw a spam email, but I didn't realize that it's really a scam at first. I gave him my telephone number, address, and name. What would he do with them? Could he ruin ALL of my reputation with it? Install Linux from Linux Interpretation of LASSO regression coefficients I'm currently working on building a predictive model for a binary outcome on a dataset with ~300 variables and 800 observations. I've read much on this site about the problems associated with stepwise regression and why not to use it.  I've been reading into LASSO regression and its ability for feature selection and have been successful in implementing it with the use of the "caret" package and "glmnet".   I am able to extract the coefficient of the model with the optimal lambda and alpha from "caret"; however, I'm unfamiliar with how to interpret the coefficients.    Are the LASSO coefficients interpreted in the same method as logistic regression? Would it be appropriate to use the features selected from LASSO in logistic regression?   EDIT  Interpretation of the coefficients, as in the exponentiated coefficients from the LASSO regression as the log odds for a 1 unit change in the coefficient while holding all other coefficients constant. I'm very new to Blender and I'm trying to make a water vortex like this.(may be not the easyest first project for a newbie)     I watched several tutorial on liquids particle etc but I'm not sure what is the best aproach. What I tried  until now:   I made a particle system with a vortex force field. It looks good, but I'm not able to add the right material.      I played around with the fluid physics, the water looks good but if I add a vortex force field it does nothing.   I would be very grateful if somebody could point me in the right direction because I'm definitely stocked. Fancy Chapter Headings Style I would like make a fancy chapter like the figure.    However, i made this code  \documentclass[12pt,a4paper]{book}   \usepackage{lmodern} \usepackage{titlesec} \usepackage{microtype} \usepackage{tikz}    \titleformat{\chapter}[display]   {\normalfont\bfseries\color{black}}   {%\filleft%     \begin{tikzpicture}     \node[       outer sep=-10pt,       text width=2.5cm,       minimum height=3cm,       fill=black,       font=\color{white}\fontsize{80}{90}\selectfont,       align=center       ] (num) {\thechapter};     \node[       rotate=0,       anchor=south,       font=\color{black}\Large\normalfont       ] at ([yshift=43pt,xshift=30]num.west)  {\textls[180]{\textsc{\chaptertitlename}}};       \end{tikzpicture}%  }    {-90pt}   {\titlerule[2.5pt]\vskip3pt\titlerule\vskip4pt\LARGE\sffamily \raggedright }    \begin{document} \chapter{The Singular Sturm-Liouville Problems in Spectral Parameter}    \end{document}      that produces this one    How can I produce the chapter like the First Figure? Interaction term positive while components are negative? I am confused about the interpretation of my interaction term , I have been through similar questions but I am still not sure about the interpretation that I should give to my output .  So this is my model , Y  stands for earnings management , X1 = CSR , X2=CEO duality , as you can see both of the coefficients are negative CSR reduces earnings management manipulation and Duality in my sample reduces em as well  which is in line with the literature and confirm my hypothesis , but to my surprise my interaction term is positive and significant does that mean that CSR combined with duality increase EM ? Or that CEO duality moderates the effect of CSR on EM knowing that in papers that I've read, they only use&quot; moderate &quot;when the interaction term and the components are all negative . Could you please help me ? I am supposed to comment my results but I don&quot;t understand this . Thank you Is it possible to test apex that relies on field history tracking? Singular or plural verb after parenthetical material containing a conjunction? I would tend to say     Sara (and all of us) have a lot to think about now.   ...but it occurs to me that if I remove the parenthetical it's clearly incorrect. Is it proper to say     Sara (and all of us) has a lot to think about now.   ...that sounds really strange to my ear.  Also, does it change the rules in any way if I use an em dash, e.g.     Sara–and all of us–have a lot to think about now. Use the new helpcenter for the question/answer ban message Related:    The helpcenter has . It still links to the  for further details. Besides that, the question ban message .  Now that we have the helpcenter, could the following changes be implemented?   Link to the help center instead of the meta post Remove the link to the meta post from the help center, and instead incorporate its contents into the helpcenter itself