I think it's 1 hour real time OR level up. So if you level up midway through a 1 hour period, it resets the 1 hour.
In the script a "gamehour" is 5 minutes long and an NPC will refresh after 12 game hours. 60 minutes.
But also checks when treasure was last generated and checks if there have been more than 12 gamehours since then. So that count should be reset on the level up trade gen. Thus it's either 12 gamehours or on level up.
Also this is all on a per NPC basis, it doesn't do them in a batch.
At least I'm pretty sure that's how it works, there are others who are more familiar with it than I.