The number of layers matters, but the actual z-index value does not work. When rendering a page, the browser simply sorts all absolutely positioned elements by their z-index (ascending) and draws them in that order.
EDIT: Also, sorting performance only happens when you change the z-index of the layers. If z-indices often do not change, then a performance hit is likely to not be noticeable. Even if you change z-indexes a lot, sorting a list of 15 items is almost instant.
source share