import os
import sys
from pathlib import Path
def writePcSampling(output_path) :
file_path = os.path.join(os.path.dirname(__file__), "../../test/ut/resources/op_profiling/instr_prof/pcSampling.bin.0")
data_8_bytes = b'\x00\x00\x02\x00\x58\x00\x00\x00'
data1 = b'\x05\x00\x00' + b'\xff' * 9 + b'\x00' * 4
data2 = b'\x05\x00\x00' + b'\x02' * 9 + b'\x00' * 4
data3 = b'\x08\x00\x00' + b'\x04' * 9 + b'\x00' * 4
data4 = b'\x01\x00\x00' + b'\x09' * 9 + b'\x00' * 4
data_reserv_bytes = b'\x00' * 2097088
directory = os.path.dirname(file_path)
if not os.path.exists(directory):
os.makedirs(directory)
with os.fdopen(os.open(file_path, os.O_WRONLY | os.O_CREAT, 0o640), 'wb') as file_handler:
file_handler.write(data_8_bytes + data1 + data2 + data3 + data4 + data_reserv_bytes)
def writeTimeLine(output_path):
file_path = output_path + "/dump/timeline.bin.0"
file = Path(file_path)
file.touch(exist_ok=True)
if __name__ == "__main__":
input = sys.argv[1]
currentDir = os.path.abspath(os.path.dirname(os.path.realpath(__file__)))
os.chdir(currentDir)
if input == "":
input = currentDir + "/../../build_ut/test/ut/resources"
writePcSampling(input)
writeTimeLine(input)