QOL fixes (#141)
- Add missing type annotations - Various style improvements - Use constants more consistently - enforce black on benchmark code
This commit is contained in:
		| @@ -8,9 +8,9 @@ class TestMessage(betterproto.Message): | ||||
|     bar: str = betterproto.string_field(1) | ||||
|     baz: float = betterproto.float_field(2) | ||||
|  | ||||
|  | ||||
| class BenchMessage: | ||||
|     """Test creation and usage a proto message. | ||||
|     """ | ||||
|     """Test creation and usage a proto message.""" | ||||
|  | ||||
|     def setup(self): | ||||
|         self.cls = TestMessage | ||||
| @@ -18,8 +18,8 @@ class BenchMessage: | ||||
|         self.instance_filled = TestMessage(0, "test", 0.0) | ||||
|  | ||||
|     def time_overhead(self): | ||||
|         """Overhead in class definition. | ||||
|         """ | ||||
|         """Overhead in class definition.""" | ||||
|  | ||||
|         @dataclass | ||||
|         class Message(betterproto.Message): | ||||
|             foo: int = betterproto.uint32_field(0) | ||||
| @@ -27,29 +27,25 @@ class BenchMessage: | ||||
|             baz: float = betterproto.float_field(2) | ||||
|  | ||||
|     def time_instantiation(self): | ||||
|         """Time instantiation | ||||
|         """ | ||||
|         """Time instantiation""" | ||||
|         self.cls() | ||||
|  | ||||
|     def time_attribute_access(self): | ||||
|         """Time to access an attribute | ||||
|         """ | ||||
|         """Time to access an attribute""" | ||||
|         self.instance.foo | ||||
|         self.instance.bar | ||||
|         self.instance.baz | ||||
|      | ||||
|  | ||||
|     def time_init_with_values(self): | ||||
|         """Time to set an attribute | ||||
|         """ | ||||
|         """Time to set an attribute""" | ||||
|         self.cls(0, "test", 0.0) | ||||
|  | ||||
|     def time_attribute_setting(self): | ||||
|         """Time to set attributes | ||||
|         """ | ||||
|         """Time to set attributes""" | ||||
|         self.instance.foo = 0 | ||||
|         self.instance.bar = "test" | ||||
|         self.instance.baz = 0.0 | ||||
|      | ||||
|  | ||||
|     def time_serialize(self): | ||||
|         """Time serializing a message to wire.""" | ||||
|         bytes(self.instance_filled) | ||||
| @@ -58,6 +54,6 @@ class BenchMessage: | ||||
| class MemSuite: | ||||
|     def setup(self): | ||||
|         self.cls = TestMessage | ||||
|      | ||||
|  | ||||
|     def mem_instance(self): | ||||
|         return self.cls() | ||||
|   | ||||
		Reference in New Issue
	
	Block a user