-
Notifications
You must be signed in to change notification settings - Fork 791
Slow processing of JSON #1425
Copy link
Copy link
Closed
Description
Can I do anything to optimize the performance of highlighting JSON in my app, or is this working as designed?
class JelloStyle(Style):
styles = {
Name.Tag: 'bold ansiblue', # key names
Keyword: 'ansibrightblack', # true, false, null
Number: 'ansimagenta', # int, float
String: 'ansigreen' # string
}
print(highlight(output, JsonLexer(), Terminal256Formatter(style=JelloStyle))[0:-1])
(I remove the last character because it seems for some reason highlight adds a newline character, but that doesn't seem to affect performance)
When I use the highlight function on a relatively large (6MB) JSON file, it adds 13 seconds to the output time:
time cat ls-R.out | jc --ls | jello -m
real 0m3.101s
user 0m1.727s
sys 0m0.537s
vs.
time cat ls-R.out | jc --ls | jello
real 0m16.916s
user 0m14.624s
sys 0m0.721s
Using the plain TerminalFormatter didn't seem to improve performance.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels