()
| 105 | |
| 106 | |
| 107 | def main(): |
| 108 | parser = argparse.ArgumentParser(description="Runs a benchmark of Marshmallow.") |
| 109 | parser.add_argument( |
| 110 | "--iterations", |
| 111 | type=int, |
| 112 | default=1000, |
| 113 | help="Number of iterations to run per test.", |
| 114 | ) |
| 115 | parser.add_argument( |
| 116 | "--repeat", |
| 117 | type=int, |
| 118 | default=5, |
| 119 | help="Number of times to repeat the performance test. The minimum will " |
| 120 | "be used.", |
| 121 | ) |
| 122 | parser.add_argument( |
| 123 | "--object-count", type=int, default=20, help="Number of objects to dump." |
| 124 | ) |
| 125 | parser.add_argument( |
| 126 | "--profile", |
| 127 | action="store_true", |
| 128 | help="Whether or not to profile marshmallow while running the benchmark.", |
| 129 | ) |
| 130 | args = parser.parse_args() |
| 131 | |
| 132 | quotes = [ |
| 133 | Quote( |
| 134 | i, |
| 135 | Author(i, "Foo", "Bar", 42, 66, "123 Fake St"), |
| 136 | "Hello World", |
| 137 | datetime.datetime(2019, 7, 4, tzinfo=datetime.timezone.utc), |
| 138 | "The World", |
| 139 | 34, |
| 140 | 3, |
| 141 | 70, |
| 142 | ) |
| 143 | for i in range(args.object_count) |
| 144 | ] |
| 145 | |
| 146 | print( |
| 147 | f"Benchmark Result: {run_timeit(quotes, args.iterations, args.repeat, profile=args.profile):.2f} usec/dump" |
| 148 | ) |
| 149 | |
| 150 | |
| 151 | if __name__ == "__main__": |
no test coverage detected
searching dependent graphs…