Exemplo n.º 1
0
# A function that adds the size of batch
def add_Batch(n):
    return n + length_Hdata


st = []  # The array of timestamps which start to inserting data
en = []  # The array of timestamps which end to inserting data
Test_time = []  # The array of test time

try:
    Timestamp = list(range(
        length_Hdata))  # First generate an array of batch size [0,1,..2047]
    for i in range(Loop):
        st.append(get_float_time_stamp())
        session.insert_records(device_ids_, Timestamp, measurements_lists_,
                               data_type_lists_, values_list_)
        en.append(get_float_time_stamp())
        # Test_time.append(en[i]-st[i])
        # print("Test_time: " + str(Test_time[i]))

        # Using add_Batch fucntion adds the size of batch to each array index
        a = list(map(add_Batch, Timestamp))
        # ex) size of batch: 2048 => [0+2048,1+2048,...2047+2048]
        # ex) if number of LOOP : 2 => [0,1,2,3,.....,2047]
        #                              [2048,2049,2050,.....4095]

finally:
    All_Test_time = en[-1] - st[0]
    print("Test_time: " + str(All_Test_time))
    Writing_frequency = (length_Hdata * Sensor * Loop) / All_Test_time
    print("Writing frequency: " + str(np.around(Writing_frequency, 2)))
Exemplo n.º 2
0
#
# with open('nor11.dat') as file:
#     data = file.read().splitlines()
#     floats=[]
#     for elem in data:
#         try:
#             floats.append(float(elem))
#         except ValueError:
#             pass
data_types_ = [TSDataType.DOUBLE]
measurements_ = ["s1"]

# for time in range(len(floats)):
#     values = [floats[time]]
#     session.insert_record("root.testdat", time, measurements_, data_types_, values)

floats = value_list[0]
for time in range(len(floats)):
    values = [floats[time]]
    session.insert_record("root.testdat", time, measurements_, data_types_,
                          values)

# insert multiple records into database
measurements_list_ = [["s1"], ["s2"]]
values_list_ = [[float(data[0])], [floats[1]]]
data_type_list_ = [data_types_, data_types_]
device_ids_ = ["root.testdat", "root.testdat"]
session.insert_records(device_ids_, [4, 5], measurements_list_,
                       data_type_list_, values_list_)