Question: I have designed a hybrid(keywords and data in same excel sheet) framework using `WebDriver`+`Java`+`TestNG`+`Maven`. I am using `PageFactory`, `Singleton Pattern` . I am using different type of HTML locators in my framework like `id`, `css`, `xpath`. I run tests on UNIX environment.

I was told that using id instead of `xpath` is faster. But how do we measure it, because when I use `xpath` and when I use `id` in both cases test gives output in same time.

Apart from avoid using `xpath`, what are other points to take care of to make project improve lot in case of speedy execution.

Answer: 
This may not be a full answer to your question but I think it fits to the topic:

I was wondering about the "id is faster than xpath" and start searching. [This SO-Question/Answer](https://stackoverflow.com/questions/16788310/what-is-the-difference-between-css-selector-xpath-which-is-betteraccording-t) gives an answer which sounds quite logical. 

But then I found these two Blogs from *Elemental Selenium*:

* [XPATH vs CSS](http://elementalselenium.com/tips/32-xpath-vs-css)
* [Css Vs. X Path, Under a Microscope](http://elementalselenium.com/tips/33-xpath-vs-css-revisited)

which shows that XPATH is faster than CSS. In the second one the author describes that he used the `benchmark` lib from ruby for his measurements.

> 
> For benchmarking I used the library that's available in Ruby's standard lib called 'benchmark'
> 
> 
> 

But as you see the numbers of his comparion you see they don't diverge so much, so I think it's better to use CSS because of the compatibility as not all browsers implementing XPATH the same way. (And yes that's not part of your question)
A typical way to measure the length of a short operation is to measure the total time required to perform the operation many times, divided by the number of times you performed it. How many times? It depends on the operation; I usually start with a small number and keep doubling it, or multiplying by ten, until the answer has as much precision as I need.

There are innumerable ways to make software faster but you did not provide enough details to recommend anything specific.