Run this module (sorts a sequence of numbers by the label of the item with the same numeric id)
local p = {} local function getLabel(id) return mw.wikibase.label(id) or '' end function p.test() local array = {} for i = 201, 400 do table.insert(array, i) end local start = os.clock() table.sort(array, function(a, b) return getLabel('Q' .. a) < getLabel('Q' .. b) end) local stop = os.clock() mw.log(stop - start) end return p
and check the result (should be around 1.5).
Now change getLabel to:
local cache = {} local function getLabel(id) if not cache[id] then cache[id] = mw.wikibase.label(id) or '' end return cache[id] end
and run again. The result should be around 0.1.
This significant difference means that repeated loading of the same label does not use (client-side) cache. (Other functions probably have the same problem.)