OK, finally tracked this down.
Change your run_test method to being inside an Undo context as show below.
Run this again and its much the same result, uncomment the single line that does set_attribute, and its 1000 times slower.
Why would running inside an Undo block with UI updates disabled do this?
Adam
def self.run_test
puts "\n#{self}"
model = Sketchup.active_model
definition = model.definitions.first
Sketchup.active_model.start_operation("MeshTest", true)
#Sketchup.active_model.set_attribute(:meaning, :life, 42);
puts "\n> Testing model.entities:"
result = self.time(model.entities)
puts "> Time: #{result}s"
puts "\n> Testing definition.entities:"
result = self.time(definition.entities)
puts "> Time: #{result}s"
Sketchup.active_model.commit_operation
end