I consider myself javascript beginner and had a question regarding measuring the performance of JavaScript code. Say I have the below code - functionA() {   start = performance.now();         // Execute some code.....   functionB();   functionC();   end = performance.now();   console.log(`Time taken: ${end - start}`); }  Will the calculated time take into account the execution time of both the sub functions? I thought JavaScript is single threaded and hence, it should be the case. Then I read somewhere that JavaScript Runtime is actually multi threaded, which makes sense because if one part of your code is taking long to execute, it can run other parts of your code in another thread. If this is indeed true and the above code would not be optimal, is there a way to measure performance which takes into account all the sub functions?
I need to get execution time in milliseconds.  I originally asked this question back in 2008. The accepted answer then was to use  However, we can all agree now  that using the standard  API is more appropriate. I am therefore changing the accepted answer to this one.
Calculate the uncertainty in velocity of electron I got this question in one of my periodic test in coaching, I (seemingly) solved the question but later recognised what mess I did.  So, the question is :      Calculate the uncertainty in velocity of an electron. If the uncertainty in its position is ${10^ {-15}} \; \mathrm m$.   By simple calculations one can see that the answer would be ${5.79\times{10^{10}}} \; \mathrm{m/s}$. However, as one can see, the uncertainty in velocity is greater than the velocity of light then how is that possible or there is some other way to handle such problems.  P.S. I know the concept of dynamic mass but I am not very familiar with it. (I think that would work here, but don't know how?) Is there any difference between Frequentist and Bayesian on the definition of Likelihood? Some sources say likelihood function is not conditional probability, some say it is. This is very confusing to me.  According to most sources I have seen, the likelihood of a distribution with parameter $\theta$, should be a product of probability mass functions given $n$ samples of $x_i$:  $$L(\theta) = L(x_1,x_2,...,x_n;\theta) = \prod_{i=1}^n p(x_i;\theta)$$  For example in Logistic Regression, we use an optimization algorithm to maximize the likelihood function (Maximum Likelihood Estimation) to obtain the optimal parameters and therefore the final LR model. Given the $n$ training samples, which we assume to be independent from each other, we want to maximize the product of probabilities (or the joint probability mass functions). This seems quite obvious to me.  According to , "likelihood is not a probability and it is not a conditional probability". It also mentioned, "likelihood is a conditional probability only in Bayesian understanding of likelihood, i.e., if you assume that $\theta$ is a random variable."  I read about the different perspectives of treating a learning problem between frequentist and Bayesian.   According to a source, for Bayesian inference, we have a priori $P(\theta)$, likelihood $P(X|\theta)$, and we want to obtain the posterior $P(\theta|X)$, using Bayesian theorem:  $$P(\theta|X)=\dfrac{P(X|\theta) \times P(\theta)}{P(X)}$$   I'm not familiar with Bayesian Inference. How come $P(X|\theta)$ which is the distribution of the observed data conditional on its parameters, is also termed the likelihood? In , it says sometimes it is written $L(\theta|X)=p(X|\theta)$. What does this mean?  is there a difference between Frequentist and Bayesian's definitions on likelihood??  Thanks.    EDIT:  There are different ways of interpreting Bayes' theorem - Bayesian interpretation and Frequentist interpretation (See: ). If $Ax = Bx$ for all $x \in C^{n}$, then $A = B$. Let $A$ and $B$ are $n\times n$ matrices and $x \in C^{n}$.  If $Ax = Bx$ for all $x$ then $A = B$. To prove this I have selected  $x$ from Euclidean basis B = {$e_{1},e_{2},...,e_{n}$}. Then $Ae_{i} = Be_{i}$ implies $i^{th}$ column of A = $i^{th}$ column of B for all $1 \leq i \leq n$. Hence $A = B.$    Is this proof complete? Prove that $u\cdot v = \frac{1}{4}||u+v||^2 - \frac{1}{4}||u-v||^2 \forall u,v \in \mathbb{R^n}$ I am trying to prove the above statement but I'm not sure if my proof is correct. My proof is as follows,  Given $u\cdot v$, we know by the C-E Inequality that $|u \cdot v| \leq ||u|| \ ||v||$  Consider $\frac{1}{4}||u+v||^2 - \frac{1}{4}||u-v||^2$  We can manipulate this as follows $$\frac{1}{4}(||u+v||^2 - ||u-v||^2) = \frac{1}{4}(||u+v||- ||u-v||)(||u+v||+||u-v||)$$ Using the triangle inequality the above can be written as follows, $$...\leq \frac{1}{4}(||u|| +||v|| -||u||+||v||) (||u|| +||v|| +||u||-||v||) = \frac{1}{4} (4||u||||v||) = ||u||||v||$$  As such both $u\cdot v$ and $u\cdot v = \frac{1}{4}||u+v||^2 - \frac{1}{4}||u-v||^2 \forall u,v \in \mathbb{R^n}$ are $\leq ||u|| ||v||$  I'm not sure whether I've proven this correctly because I ended up proving that both sides of the equation are less than or equal to something entirely different (the magnitude of v multiplied by the magnitude of u). Is this acceptable? I don't think it is, since if both can be less than or equal to the magnitudes multiplied then they do not necessarily have to be equal to each other. If this is the case, can someone give me a hint on how to move forward with this proof? Although many have attempted to explain the difference among \mathrm, \textrm, \textnormal and \text (and others?), I found them misleading.  See for example the LaTeX's Wiki \mathrm explanation   Why is it wrong? Let's try all of them within an article and a beamer and you'll see the difference and, therefore, error.  equation.tex  \begin{eqnarray*}   \int_1^9\! \cos{x} \,\mathrm{d}x &amp; &amp; \textrm{this is textrm}\   \sum_1^9 y                       &amp; &amp; \textsf{this is textsf}\   \prod_1^9 z                      &amp; &amp; \textnormal{this is textnormal}\   \bigcup_1^9 w                    &amp; &amp; \text{and this is just text} \end{eqnarray*}   article.tex  \documentclass{article} \usepackage{amsmath} \usepackage{amsfonts} \usepackage{amssymb}  \begin{document}   \input {equation} \end{document}     And until here everything looks fine...  beamer.tex  \documentclass{beamer} \usepackage{amsmath} \usepackage{amsfonts} \usepackage{amssymb}  \begin{document}   \begin{frame}     \input{equation}   \end{frame} \end{document}     And here we can clearly see that \mathrm does not behave as expected, i.e. does not provide a function aspect to the d. Does anyone know what am I supposed to use here instead? Just \text?? o.O  Moreover, I cannot see any difference between \textnormal and \text.  Finally, \textrm looks useless.. How can I make a time delay in Python? I would like to know how to put a time delay in a Python script. A familiar limit, but in general form . Deriving Chinese Remainder Theorem from gcd Bezout identity Evaluating $ \lim_{x \rightarrow 0}\left (\frac{\sin(x)}{x}\right)^\frac{1}{x^2}$ Difference of $R^2$ between OLS with individual dummies to panel fixed effect model? Based on my understanding, panel fixed effect model is equivalent to OLS with individual dummies. However, when I ran the two models in R, the $R^2$ from the two models were quite different: 0.8 for OLS with individual dummies and 0.06 for fixed effect model.  Is it the case that in fixed effect model, the fixed effects (individual dummies) are excluded from the calculation of $R^2$? I'm adding a title clock in the foot line of a beamer slide, if I compile it with pdfLaTeX it works fine; while the clock doesn't align in the middle vertically if compiling with XeLaTeX. How can I fix this.  Here is my MWE:  \documentclass[10pt]{beamer} \usepackage[font=Times,timeinterval=1]{tdclock} \usetheme{Madrid} \title{Title} \author{Authors} \institute{Institute} \date[\initclock\tddate\ \ \tdtime]{\today} \begin{document} \frame{\titlepage} \end{document} Given, $\{x_n\}$ and $\{y_n\}$ are two real valued sequences such that $\lim_{n\to\infty} (x_{n}^{3}-y_{n}^{3})=0 $ Then is it always true that $\lim_{n\to\infty} (x_n-y_n) =0 $ ? I tried by splitting $ (x_{n}^{3}-y_{n}^{3}) $, but that didn't help as $\lim_{n\to \infty} (x_{n}^{2}+x_{n}y_{n}+y_{n}^{2}) $ can be $0$ or non zero or doesn't exist. SEO safe way to run beta of new site on seperate domain I know the usage of     This is a new car.   This is singular.     These are some books for you.   These is plural.  Shall we use   There exists some people who agree with me. There exist some people who agree with me.   Which one is the correct usage and why? How does a credit card company make any money off of me using their card if there are no fees associated with the card (I don't pay any extra) and I pay off my balance on time every month (so I don't pay any fees ever for this either).  Are they just banking on the fact that many people don't do this and end up owing them money? How can I get a pure white background in jewelry photography, without losing sparkle and shine? I've read through several threads similar to this, but I'm looking for a comparison of two options here.   I currently take photos on a raised glass platform against a white foam board background and run about 300w of lights (3 100x LEDs @ 5000k, Home Depot Specials in softboxes and umbrellas). As you can imagine, it takes me about 15 minutes of post processing to achieve a perfect white background, and sometimes I have a particular photo that I am unable to get there.  I want to upgrade to either a photography table with a translucent background that I can place a speedlight under, or a cyclorama infinity background such as the MyStudio MS20. The latter option may require an upgrade to my lighting, which I am planning to do anyways.  The idea of course is to get a blown out 255 background with no post processing, other than color correction on the jewelry or product as needed. This would cut my time after the shoot to a ridiculously small amount of time.   Which option would make my life easier?   For reference, I currently use a D5300 with a Tamron 90mm f2.8 macro lens.  This is the best shot I got after quite a lot of effort, before and after processing:      Note that the silver is not shiny like it should be, and the sparkle on the gems is lost. Does the lens I just bought have a fungus? I'm having trouble figuring out how to iterate over map layers. I can access the currently highlighted layer in the table of contents via iface.activeLayer() but I want my code to operate on all layers.  I don't see anything in the API that provides easy access to this functionality and couldn't find a good online example but maybe I missed something? Error message "sudo: unable to resolve host (none)" When I run sudo the terminal is stuck for a few seconds and then outputs an error message. My terminal looks like this:  ubuntu@(none):~$ sudo true sudo: unable to resolve host (none)   What can I do to solve it? I'm going to guess that the answer is "no" based on the below error message (and ), but is there anyway to perform a cross-database query using PostgreSQL?  databaseA=# select * from databaseB.public.someTableName; ERROR:  cross-database references are not implemented:  "databaseB.public.someTableName"   I'm working with some data that is partitioned across two databases although data is really shared between the two (userid columns in one database come from the users table in the other database). I have no idea why these are two separate databases instead of schema, but c'est la vie...