fad862d618
- Introduced `benchmark_saved_state.gd` to evaluate the performance of the saved state restoration process. - Implemented JSON integer restoration to handle large integers accurately. - Added command-line argument parsing for specifying the path to the diagnostic JSON file and optional delta seconds. - Conducted performance tests at different speeds and logged the elapsed time for six consecutive steps. - Created a new UID file for the benchmark script.
37 lines
871 B
GDScript
37 lines
871 B
GDScript
class_name CSVLoader
|
|
|
|
const SPLITTER = '|'
|
|
|
|
static func load(csv_text: String) -> Dictionary:
|
|
var result: Dictionary = {}
|
|
|
|
var lines := csv_text.strip_edges().split("\n")
|
|
|
|
if lines.size() < 2:
|
|
return result
|
|
|
|
var headers := lines[0].split(SPLITTER)
|
|
|
|
for i in range(1, lines.size()):
|
|
var line := lines[i].strip_edges()
|
|
|
|
if line.is_empty():
|
|
continue
|
|
|
|
var values := line.split(SPLITTER)
|
|
|
|
if values.size() != headers.size():
|
|
push_warning(
|
|
"CSV row %d has %d columns, expected %d"
|
|
% [i + 1, values.size(), headers.size()]
|
|
)
|
|
continue
|
|
|
|
var elem: Dictionary = {}
|
|
|
|
for j in range(headers.size()):
|
|
elem[headers[j].strip_edges()] = values[j].strip_edges()
|
|
|
|
result[elem[headers[0]]] = elem
|
|
return result
|