Skip to content

Performance of converting .asc files to MDF files (asammdf >= 8.1.0) #1246

@MalGroTD

Description

@MalGroTD

Hi Daniel,

I made a comment on issue [#1240], but it seems to be a seperate issue, so i created a new one.
Here is the original comment:

Hello everyone,

This is my first comment, and I’m new to GitHub. I hope it’s okay to contribute here instead of opening a new issue.

I’m adding my input here, because I’ve noticed performance drops starting with version 8.1.0 (compared to 8.0.0), too. Specifically, I experience these performance drops when converting .asc files to .mf4 files with python-can.

.asc file can be generated using:

import datetime


def generate_rx_lines_to_asc(filename, n):
    time = 3.460000
    third = 9000
    length = 1704087
    bitcount = 232
    start_id = int("888888DF", 16)

    # Current datetime for header
    now = datetime.datetime.now()
    date_str = now.strftime("%a %b %d %H:%M:%S.%f %Y")[:-3]  # ASC format

    with open(filename, "w") as f:
        # Write header
        f.write(f"date {date_str}\n")
        f.write("base hex  timestamps absolute\n")
        f.write("internal events logged\n")
        f.write(f"Begin Triggerblock {date_str}\n")
        f.write("0.000000 Start of measurement\n")

        # Write messages
        for i in range(n):
            line = (
                f"{time:.6f} 2 {third} Rx r 8 "
                f"Length = {length} BitCount = {bitcount} "
                f"ID = {hex(start_id + i)[2:].upper()}x\n"
            )
            f.write(line)

            # update values
            time += 0.01
            third += 100
            length += 1
            bitcount += 1

        # Write footer
        f.write("End Triggerblock\n")


# Example: generate 100 lines into 'output.asc'
generate_rx_lines_to_asc("test/data/generated/output.asc", 30_000)

I first had a custom function that used reader and writer to convert, but the performance drop can also be reproduced with the default can.logconvert from python-can

import subprocess
import sys
import time

ASC_FILE = "test/data/generated/output.asc"
MF4_FILE = "test/data/generated/output.mf4"

start_time =  time.time()

command = [sys.executable, "-m", "can.logconvert", ASC_FILE, MF4_FILE]
subprocess.run(command)

end_time = time.time()
duration = end_time - start_time
print(f"Conversion finished in {duration:.2f} seconds.")

I have already tried the development branch code with

pip install git+https://github.com/danielhrisca/asammdf.git@development

where i got asammdf-8.7.0.dev6 (I hope that´s the right way to get the dev branch), but I got the same performance drop.

Python: 3.13.7
python-can: 4.6.1
asammdf: 8.0.0 / 8.1.0

Thank you for your great project! I am really learning a lot from it.

Originally posted by @MalGroTD in #1240

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions