What is completion percentage based on?

Octoprint displays a bar that shows the percentage of the current print, but what is it a percentage of? Is it a percentage of the total print time, total number of layers, amount of filament used, or what?

IIRC, the stock percentage meter is based on lines of gcode executed. If all of your moves are similar, it can be very close to time. If your ratio of long/short moves is different throughout the file, it could be fairly inaccurate as long moves take more time, but still only count as one line of code.

There are several plugins out there that use different algorithms to get "better" estimations compared with runtime. Personally, I use PrintTimeGenius which analyses the gcode including the speed and distance of every move to estimate time. In my use cases, I've found it to be very close to the true runtime.