diff --git a/tools/api_proto_plugin/plugin.py b/tools/api_proto_plugin/plugin.py index 75ec9b40bbe0..2ae9dfb44fc9 100644 --- a/tools/api_proto_plugin/plugin.py +++ b/tools/api_proto_plugin/plugin.py @@ -1,9 +1,5 @@ """Python protoc plugin for Envoy APIs.""" -import cProfile -import io -import os -import pstats import sys from collections import namedtuple @@ -54,7 +50,6 @@ def plugin(output_descriptors, traverser=None): request = plugin_pb2.CodeGeneratorRequest() request.ParseFromString(sys.stdin.buffer.read()) response = plugin_pb2.CodeGeneratorResponse() - cprofile_enabled = os.getenv('CPROFILE_ENABLED') # We use request.file_to_generate rather than request.file_proto here since we # are invoked inside a Bazel aspect, each node in the DAG will be visited once @@ -62,9 +57,6 @@ def plugin(output_descriptors, traverser=None): for file_to_generate in request.file_to_generate: # Find the FileDescriptorProto for the file we actually are generating. file_proto = [pf for pf in request.proto_file if pf.name == file_to_generate][0] - if cprofile_enabled: - pr = cProfile.Profile() - pr.enable() for od in output_descriptors: f = response.file.add() f.name = f"{file_proto.name}{od.output_suffix}" @@ -76,18 +68,4 @@ def plugin(output_descriptors, traverser=None): xformed_proto = od.xform(file_proto) visitor_factory = od.visitor_factory() f.content = traverser(xformed_proto, visitor_factory) - if cprofile_enabled: - pr.disable() - stats_stream = io.StringIO() - ps = pstats.Stats( - pr, stream=stats_stream).sort_stats(os.getenv('CPROFILE_SORTBY', 'cumulative')) - stats_file = response.file.add() - stats_file.name = file_proto.name + '.profile' - ps.print_stats() - stats_file.content = stats_stream.getvalue() - # Also include the original FileDescriptorProto as text proto, this is - # useful when debugging. - descriptor_file = response.file.add() - descriptor_file.name = file_proto.name + ".descriptor.proto" - descriptor_file.content = str(file_proto) sys.stdout.buffer.write(response.SerializeToString())