MCPcopy Create free account
hub / github.com/awesomebytes/rclcppyy / run_python_copy

Function run_python_copy

scripts/bench_rosbag2_cpp_vs_py.py:36–76  ·  view source on GitHub ↗
(args: Args)

Source from the content-addressed store, hash-verified

34
35
36def run_python_copy(args: Args):
37 reader = SequentialReader()
38 reader.open(StorageOptions(uri=args.input_uri, storage_id=args.storage_id),
39 ConverterOptions(input_serialization_format=args.serialization, output_serialization_format=args.serialization))
40 writer = SequentialWriter()
41 writer.open(StorageOptions(uri=args.output_uri_py, storage_id=args.storage_id),
42 ConverterOptions(input_serialization_format=args.serialization, output_serialization_format=args.serialization))
43
44 try:
45 topics = reader.get_all_topics_and_types()
46 except AttributeError:
47 topics = reader.get_topics_and_types()
48
49 for t in topics:
50 writer.create_topic(TopicMetadata(
51 id=0,
52 name=t.name,
53 type=t.type,
54 serialization_format=args.serialization
55 ))
56
57 has_next = reader.has_next
58 read_next = reader.read_next
59 write = writer.write
60
61 gc_was_enabled = gc.isenabled()
62 if gc_was_enabled:
63 gc.disable()
64 try:
65 t0 = time.time()
66 count = 0
67 while has_next():
68 topic, data, ts = read_next()
69 write(topic, data, ts)
70 count += 1
71 t1 = time.time()
72 finally:
73 if gc_was_enabled:
74 gc.enable()
75 gc.collect()
76 return t1 - t0, count
77
78
79def run_cxx_copy(args: Args):

Callers 1

mainFunction · 0.85

Calls 9

openMethod · 0.95
openMethod · 0.95
create_topicMethod · 0.95
SequentialReaderClass · 0.90
StorageOptionsClass · 0.90
ConverterOptionsClass · 0.90
SequentialWriterClass · 0.90
TopicMetadataClass · 0.90

Tested by

no test coverage detected