@plac.annotations(<EOL>model=("<STR_LIT>", "<STR_LIT>", None, str),<EOL>inputs=("<STR_LIT>", "<STR_LIT>", None, str),<EOL>n_texts=("<STR_LIT>", "<STR_LIT>", "<STR_LIT:n>", int),<EOL>)<EOL>def profile(model, inputs=None, n_texts=<NUM_LIT>):
msg = Printer()<EOL>if inputs is not None:<EOL><INDENT>inputs = _read_inputs(inputs, msg)<EOL><DEDENT>if inputs is None:<EOL><INDENT>n_inputs = <NUM_LIT><EOL>with msg.loading("<STR_LIT>"):<EOL><INDENT>imdb_train, _ = thinc.extra.datasets.imdb()<EOL>inputs, _ = zip(*imdb_train)<EOL><DEDENT>msg.info("<STR_LIT>".format(n_inputs))<EOL>inputs = inputs[:n_inputs]<EOL><DEDENT>with msg.loading("<STR_LIT>".format(model)):<EOL><INDENT>nlp = load_model(model)<EOL><DEDENT>msg.good("<STR_LIT>".format(model))<EOL>texts = list(itertools.islice(inputs, n_texts))<EOL>cProfile.runctx("<STR_LIT>", globals(), locals(), "<STR_LIT>")<EOL>s = pstats.Stats("<STR_LIT>")<EOL>msg.divider("<STR_LIT>")<EOL>s.strip_dirs().sort_stats("<STR_LIT:time>").print_stats()<EOL>
Profile a spaCy pipeline, to find out which functions take the most time.
Input should be formatted as one JSON object per line with a key "text".
It can either be provided as a JSONL file, or be read from sys.sytdin.
If no input file is specified, the IMDB dataset is loaded via Thinc.