MCPcopy Create free account
hub / github.com/PyTables/PyTables / create_file

Function create_file

bench/table-bench.py:47–139  ·  view source on GitHub ↗
(filename, totalrows, filters, recsize)

Source from the content-addressed store, hash-verified

45
46
47def create_file(filename, totalrows, filters, recsize):
48
49 # Open a file in "w"rite mode
50 fileh = tb.open_file(
51 filename, mode="w", title="Table Benchmark", filters=filters
52 )
53
54 # Table title
55 title = "This is the table title"
56
57 # Create a Table instance
58 group = fileh.root
59 rowswritten = 0
60 for j in range(3):
61 # Create a table
62 if recsize == "big":
63 table = fileh.create_table(
64 group, "tuple" + str(j), Big, title, None, totalrows
65 )
66 elif recsize == "medium":
67 table = fileh.create_table(
68 group, "tuple" + str(j), Medium, title, None, totalrows
69 )
70 elif recsize == "small":
71 table = fileh.create_table(
72 group, "tuple" + str(j), Small, title, None, totalrows
73 )
74 else:
75 raise RuntimeError("This should never happen")
76
77 table.attrs.test = 2
78 rowsize = table.rowsize
79 # Get the row object associated with the new table
80 d = table.row
81 # Fill the table
82 if recsize == "big":
83 for i in range(totalrows):
84 # d['name'] = 'Part: %6d' % (i)
85 d["TDCcount"] = i % 256
86 # d['float1'] = NP.array([i]*32, NP.float64)
87 # d['float2'] = NP.array([i**2]*32, NP.float64)
88 # d['float1'][0] = float(i)
89 # d['float2'][0] = float(i*2)
90 # Common part with medium
91 d["grid_i"] = i
92 d["grid_j"] = 10 - i
93 d["pressure"] = float(i * i)
94 # d['energy'] = float(d['pressure'] ** 4)
95 d["energy"] = d["pressure"]
96 # d['idnumber'] = i * (2 ** 34)
97 d.append()
98 elif recsize == "medium":
99 for i in range(totalrows):
100 # d['name'] = 'Part: %6d' % (i)
101 # d['float1'] = NP.array([i]*2, NP.float64)
102 # d['float1'] = arr
103 # d['float1'] = i
104 # d['float2'] = float(i)

Callers 1

table-bench.pyFile · 0.70

Calls 5

create_groupMethod · 0.80
create_tableMethod · 0.45
appendMethod · 0.45
flushMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected