Skip to content

feat(medcat):CU-869cgny1k Add pipe speed options#369

Merged
mart-r merged 10 commits intomainfrom
feat/medcat/CU-869cgny1k-add-pipe-speed-options
Mar 17, 2026
Merged

feat(medcat):CU-869cgny1k Add pipe speed options#369
mart-r merged 10 commits intomainfrom
feat/medcat/CU-869cgny1k-add-pipe-speed-options

Conversation

@mart-r
Copy link
Copy Markdown
Collaborator

@mart-r mart-r commented Mar 16, 2026

This PR adds a few options for inspecting speed of the pipe.

The idea is to add it in a way that doesn't interfere with the regular inference. I.e something with 0 overhead during normal operation yet close enough to regular use cases.

The added methods are:

  • medcat.pipeline.speed_utils.pipeline_per_doc_timer
  • medcat.pipeline.speed_utils.pipeline_timer_averaging_docs
  • medcat.pipeline.speed_utils.profile_pipeline_component

The idea is that you first use one of the first two to figure out which component is taking the most time.
And then you profiile that component to figure out why it's slower than expected (if that is the case).

EDIT:
I've also added an option to provide your own timer into pipeline_per_doc_timer for more customisability. This can be whatever that follows the same base interface so (effectively) this approach could be used to replace the other 2 methods as well.

Example code / usage
from medcat.components.types import CoreComponentType
from medcat.cat import CAT
from medcat.pipeline.speed_utils import pipeline_per_doc_timer, pipeline_timer_averaging_docs, profile_pipeline_component

path = ".temp/20230227__kch_gstt_trained_model_f76d2121b77c3e9a.zip"

print("Loading")
cat = CAT.load_model_pack(path)
print("RUN!")

texts = [
    """
    Description: Intracerebral hemorrhage (very acute clinical changes occurred immediately).
CC: Left hand numbness on presentation; then developed lethargy later that day.

HX: On the day of presentation, this 72 y/o RHM suddenly developed generalized weakness and lightheadedness, and could not rise from a chair. Four hours later he experienced sudden left hand numbness lasting two hours. There were no other associated symptoms except for the generalized weakness and lightheadedness. He denied vertigo.

He had been experiencing falling spells without associated LOC up to several times a month for the past year.

MEDS: procardia SR, Lasix, Ecotrin, KCL, Digoxin, Colace, Coumadin.

PMH: 1)8/92 evaluation for presyncope (Echocardiogram showed: AV fibrosis/calcification, AV stenosis/insufficiency, MV stenosis with annular calcification and regurgitation, moderate TR, Decreased LV systolic function, severe LAE. MRI brain: focal areas of increased T2 signal in the left cerebellum and in the brainstem probably representing microvascular ischemic disease. IVG (MUGA scan)revealed: global hypokinesis of the LV and biventricular dysfunction, RV ejection Fx 45% and LV ejection Fx 39%. He was subsequently placed on coumadin severe valvular heart disease), 2)HTN, 3)Rheumatic fever and heart disease, 4)COPD, 5)ETOH abuse, 6)colonic polyps, 7)CAD, 8)CHF, 9)Appendectomy, 10)Junctional tachycardia.
    """,
    """
    Patient Information:

Name: John Parkinson
Date of Birth: February 12, 1958
Gender: Male
Address: 789 Wellness Lane, Healthville, HV 56789
Phone: (555) 555-1234
Email: john.parkinson@email.com
Emergency Contact:

Name: Mary Parkinson
Relationship: Spouse
Phone: (555) 555-5678
Insurance Information:

Insurance Provider: HealthWell Assurance
Policy Number: HW765432109
Group Number: G876543
Medical History:

Allergies:

None reported
Medications:

Levodopa/Carbidopa for Parkinson's disease symptoms
Pramipexole for restless legs syndrome
Lisinopril for hypertension
Atorvastatin for hyperlipidemia
Metformin for Type 2 Diabetes
Medical Conditions:

Parkinson's Disease (diagnosed on June 20, 2015)
Hypertension
Hyperlipidemia
Type 2 Diabetes
Osteoarthritis
Vital Signs:

Blood Pressure: 130/80 mmHg
Heart Rate: 72 bpm
Temperature: 98.4°F
Respiratory Rate: 18 breaths per minute
Recent Inpatient Stay (Dates: September 1-10, 2023):

Reason for Admission: Acute exacerbation of Parkinson's symptoms, pneumonia, and uncontrolled diabetes.

Interventions:

Neurology Consultation for Parkinson's disease management adjustments.
Antibiotic therapy for pneumonia.
Continuous glucose monitoring and insulin therapy for diabetes control.
Physical therapy sessions to maintain mobility.
Complications:

Delirium managed with close monitoring and appropriate interventions.
Discharge Plan:

Medication adjustments for Parkinson's disease.
Follow-up appointments with neurologist, endocrinologist, and primary care.
Home health care for continued physical therapy.
Follow-up Visits:

Date: October 15, 2023

Reason for Visit: Post-discharge Follow-up
Notes: Stable Parkinson's symptoms, pneumonia resolved. Adjusted diabetes medications for better control.
Date: December 5, 2023

Reason for Visit: Neurology Follow-up
Notes: Fine-tuned Parkinson's medication regimen. Recommended ongoing physical therapy.
    """
]*5

print("\n***PER DOC\n")
with pipeline_per_doc_timer(cat.pipe):
    for text in texts:
        cat.get_entities(text)

print("\n***Every 0.3s\n")
with pipeline_timer_averaging_docs(cat.pipe, show_frequency_secs=0.3):
    for text in texts:
        cat.get_entities(text)

print("\n***Every 4 docs\n")
with pipeline_timer_averaging_docs(cat.pipe, show_frequency_docs=4):
    for text in texts:
        cat.get_entities(text)

print("\n***Defaults to 100 docs\n")
with pipeline_timer_averaging_docs(cat.pipe):
    for text in texts:
        cat.get_entities(text)

print("\n***Look at specific component\n")
with profile_pipeline_component(cat.pipe, CoreComponentType.ner):
    for text in texts:
        cat.get_entities(text)
Example output
  Loading
/Users/martratas/Documents/CogStack/.MedCAT.nosync/monorepo-nlp/medcat-v2/.venv312/lib/python3.12/site-packages/spacy/util.py:922: UserWarning: [W095] Model 'en_core_web_md' (3.1.0) was trained with spaCy v3.1.0 and may not be 100% compatible with the current version (3.8.7). If you see errors or degraded performance, download a newer compatible model or retrain your custom model with the current spaCy version. For more details and available updates, run: python -m spacy validate
  warnings.warn(warn_msg)
RUN!

***PER DOC

Component tagging:tag-and-skip-tagger took 0.768ms
Component token_normalizing:token_normalizer took 9.207ms
Component ner:cat_ner took 2575.080ms
Component linking:medcat2_linker took 31.518ms
Component meta_cat.Presence took 96.082ms
Component meta_cat.Subject took 72.186ms
Component meta_cat.Time took 70.054ms
Component tagging:tag-and-skip-tagger took 1.194ms
Component token_normalizing:token_normalizer took 5.497ms
Component ner:cat_ner took 12.642ms
Component linking:medcat2_linker took 38.639ms
Component meta_cat.Presence took 95.667ms
Component meta_cat.Subject took 93.069ms
Component meta_cat.Time took 91.621ms
Component tagging:tag-and-skip-tagger took 0.655ms
Component token_normalizing:token_normalizer took 5.822ms
Component ner:cat_ner took 2.929ms
Component linking:medcat2_linker took 27.524ms
Component meta_cat.Presence took 69.697ms
Component meta_cat.Subject took 68.354ms
Component meta_cat.Time took 67.990ms
Component tagging:tag-and-skip-tagger took 1.075ms
Component token_normalizing:token_normalizer took 4.977ms
Component ner:cat_ner took 4.237ms
Component linking:medcat2_linker took 36.132ms
Component meta_cat.Presence took 89.256ms
Component meta_cat.Subject took 89.293ms
Component meta_cat.Time took 89.246ms
Component tagging:tag-and-skip-tagger took 0.649ms
Component token_normalizing:token_normalizer took 6.310ms
Component ner:cat_ner took 3.072ms
Component linking:medcat2_linker took 28.319ms
Component meta_cat.Presence took 68.372ms
Component meta_cat.Subject took 67.786ms
Component meta_cat.Time took 69.316ms
Component tagging:tag-and-skip-tagger took 1.020ms
Component token_normalizing:token_normalizer took 4.967ms
Component ner:cat_ner took 4.394ms
Component linking:medcat2_linker took 36.105ms
Component meta_cat.Presence took 90.727ms
Component meta_cat.Subject took 89.385ms
Component meta_cat.Time took 91.127ms
Component tagging:tag-and-skip-tagger took 0.645ms
Component token_normalizing:token_normalizer took 5.852ms
Component ner:cat_ner took 2.898ms
Component linking:medcat2_linker took 28.496ms
Component meta_cat.Presence took 67.063ms
Component meta_cat.Subject took 69.758ms
Component meta_cat.Time took 70.006ms
Component tagging:tag-and-skip-tagger took 1.014ms
Component token_normalizing:token_normalizer took 5.235ms
Component ner:cat_ner took 4.266ms
Component linking:medcat2_linker took 35.604ms
Component meta_cat.Presence took 91.102ms
Component meta_cat.Subject took 89.923ms
Component meta_cat.Time took 93.905ms
Component tagging:tag-and-skip-tagger took 0.716ms
Component token_normalizing:token_normalizer took 6.166ms
Component ner:cat_ner took 2.924ms
Component linking:medcat2_linker took 27.451ms
Component meta_cat.Presence took 68.804ms
Component meta_cat.Subject took 68.407ms
Component meta_cat.Time took 67.972ms
Component tagging:tag-and-skip-tagger took 1.074ms
Component token_normalizing:token_normalizer took 5.014ms
Component ner:cat_ner took 4.099ms
Component linking:medcat2_linker took 36.160ms
Component meta_cat.Presence took 89.377ms
Component meta_cat.Subject took 89.439ms
Component meta_cat.Time took 89.157ms

***Every 0.3s

Component ner:cat_ner took (min/mean/median/average): 2.913ms / 3.464ms / 3.464ms / 4.016msover 2 docs and a total of 0.303s
Component linking:medcat2_linker took (min/mean/median/average): 26.497ms / 31.288ms / 31.288ms / 36.079msover 2 docs and a total of 0.339s
Component meta_cat.Presence took (min/mean/median/average): 67.122ms / 78.821ms / 78.821ms / 90.520msover 2 docs and a total of 0.429s
Component meta_cat.Subject took (min/mean/median/average): 67.284ms / 79.111ms / 79.111ms / 90.938msover 2 docs and a total of 0.520s
Component meta_cat.Time took (min/mean/median/average): 67.191ms / 78.048ms / 78.048ms / 88.906msover 2 docs and a total of 0.609s
Component tagging:tag-and-skip-tagger took (min/mean/median/average): 0.658ms / 0.781ms / 0.669ms / 1.017msover 3 docs and a total of 0.635s
Component token_normalizing:token_normalizer took (min/mean/median/average): 4.572ms / 5.498ms / 5.663ms / 6.259msover 3 docs and a total of 0.641s
Component ner:cat_ner took (min/mean/median/average): 2.884ms / 2.884ms / 2.884ms / 2.884msover 1 docs and a total of 0.341s
Component linking:medcat2_linker took (min/mean/median/average): 27.519ms / 27.519ms / 27.519ms / 27.519msover 1 docs and a total of 0.333s
Component meta_cat.Presence took (min/mean/median/average): 68.620ms / 68.620ms / 68.620ms / 68.620msover 1 docs and a total of 0.311s
Component meta_cat.Presence took (min/mean/median/average): 90.371ms / 90.371ms / 90.371ms / 90.371msover 1 docs and a total of 0.305s
Component meta_cat.Subject took (min/mean/median/average): 67.577ms / 78.566ms / 78.566ms / 89.555msover 2 docs and a total of 0.615s
Component meta_cat.Time took (min/mean/median/average): 66.538ms / 78.103ms / 78.103ms / 89.669msover 2 docs and a total of 0.615s
Component tagging:tag-and-skip-tagger took (min/mean/median/average): 0.657ms / 0.899ms / 0.899ms / 1.141msover 2 docs and a total of 0.615s
Component token_normalizing:token_normalizer took (min/mean/median/average): 4.816ms / 5.296ms / 5.296ms / 5.775msover 2 docs and a total of 0.615s
Component ner:cat_ner took (min/mean/median/average): 2.918ms / 3.657ms / 3.657ms / 4.396msover 2 docs and a total of 0.615s
Component linking:medcat2_linker took (min/mean/median/average): 27.406ms / 32.062ms / 32.062ms / 36.719msover 2 docs and a total of 0.615s
Component meta_cat.Presence took (min/mean/median/average): 66.796ms / 66.796ms / 66.796ms / 66.796msover 1 docs and a total of 0.308s
Component meta_cat.Presence took (min/mean/median/average): 88.607ms / 88.607ms / 88.607ms / 88.607msover 1 docs and a total of 0.301s
Component meta_cat.Subject took (min/mean/median/average): 67.773ms / 78.384ms / 78.384ms / 88.994msover 2 docs and a total of 0.609s
Component meta_cat.Time took (min/mean/median/average): 67.521ms / 78.124ms / 78.124ms / 88.727msover 2 docs and a total of 0.608s
Component tagging:tag-and-skip-tagger took (min/mean/median/average): 0.676ms / 0.854ms / 0.854ms / 1.032msover 2 docs and a total of 0.609s
Component token_normalizing:token_normalizer took (min/mean/median/average): 4.643ms / 5.267ms / 5.267ms / 5.891msover 2 docs and a total of 0.609s
Component ner:cat_ner took (min/mean/median/average): 2.999ms / 3.512ms / 3.512ms / 4.025msover 2 docs and a total of 0.609s
Component linking:medcat2_linker took (min/mean/median/average): 26.735ms / 30.488ms / 30.488ms / 34.242msover 2 docs and a total of 0.608s
Component meta_cat.Presence took (min/mean/median/average): 68.767ms / 68.767ms / 68.767ms / 68.767msover 1 docs and a total of 0.308s
Component meta_cat.Presence took (min/mean/median/average): 89.901ms / 89.901ms / 89.901ms / 89.901msover 1 docs and a total of 0.313s
Component meta_cat.Subject took (min/mean/median/average): 72.917ms / 81.719ms / 81.719ms / 90.521msover 2 docs and a total of 0.623s
Component meta_cat.Time took (min/mean/median/average): 71.951ms / 80.861ms / 80.861ms / 89.772msover 2 docs and a total of 0.624s
Component tagging:tag-and-skip-tagger took (min/mean/median/average): 0.680ms / 0.841ms / 0.841ms / 1.002msover 2 docs and a total of 0.624s
Component token_normalizing:token_normalizer took (min/mean/median/average): 4.550ms / 5.278ms / 5.278ms / 6.006msover 2 docs and a total of 0.624s
Component ner:cat_ner took (min/mean/median/average): 3.018ms / 3.520ms / 3.520ms / 4.021msover 2 docs and a total of 0.624s
Component linking:medcat2_linker took (min/mean/median/average): 27.412ms / 31.463ms / 31.463ms / 35.515msover 2 docs and a total of 0.625s
Component meta_cat.Presence took (min/mean/median/average): 69.567ms / 69.567ms / 69.567ms / 69.567msover 1 docs and a total of 0.313s
Component meta_cat.Presence took (min/mean/median/average): 90.063ms / 90.063ms / 90.063ms / 90.063msover 1 docs and a total of 0.306s
Component meta_cat.Subject took (min/mean/median/average): 68.071ms / 78.340ms / 78.340ms / 88.609msover 2 docs and a total of 0.616s
Component meta_cat.Time took (min/mean/median/average): 68.469ms / 79.518ms / 79.518ms / 90.567msover 2 docs and a total of 0.617s
Component tagging:tag-and-skip-tagger took (min/mean/median/average): 1.061ms / 1.061ms / 1.061ms / 1.061msover 1 docs and a total of 0.594s
Component token_normalizing:token_normalizer took (min/mean/median/average): 4.699ms / 4.699ms / 4.699ms / 4.699msover 1 docs and a total of 0.588s
Component ner:cat_ner took (min/mean/median/average): 4.151ms / 4.151ms / 4.151ms / 4.151msover 1 docs and a total of 0.585s
Component linking:medcat2_linker took (min/mean/median/average): 35.472ms / 35.472ms / 35.472ms / 35.472msover 1 docs and a total of 0.557s

***Every 4 docs

Component tagging:tag-and-skip-tagger took (min/mean/median/average): 0.646ms / 0.846ms / 0.834ms / 1.072msover 4 docs and a total of 0.915s
Component token_normalizing:token_normalizer took (min/mean/median/average): 4.694ms / 5.285ms / 5.260ms / 5.926msover 4 docs and a total of 0.920s
Component ner:cat_ner took (min/mean/median/average): 2.977ms / 3.509ms / 3.478ms / 4.105msover 4 docs and a total of 0.924s
Component linking:medcat2_linker took (min/mean/median/average): 26.459ms / 33.903ms / 31.488ms / 46.176msover 4 docs and a total of 0.970s
Component meta_cat.Presence took (min/mean/median/average): 67.565ms / 79.292ms / 79.427ms / 90.749msover 4 docs and a total of 1.060s
Component meta_cat.Subject took (min/mean/median/average): 68.460ms / 79.025ms / 78.842ms / 89.955msover 4 docs and a total of 1.150s
Component meta_cat.Time took (min/mean/median/average): 68.365ms / 79.366ms / 78.978ms / 91.145msover 4 docs and a total of 1.242s
Component tagging:tag-and-skip-tagger took (min/mean/median/average): 0.661ms / 0.837ms / 0.832ms / 1.022msover 4 docs and a total of 1.278s
Component token_normalizing:token_normalizer took (min/mean/median/average): 4.891ms / 5.855ms / 5.809ms / 6.911msover 4 docs and a total of 1.278s
Component ner:cat_ner took (min/mean/median/average): 2.869ms / 3.474ms / 3.457ms / 4.111msover 4 docs and a total of 1.278s
Component linking:medcat2_linker took (min/mean/median/average): 27.315ms / 31.206ms / 31.019ms / 35.473msover 4 docs and a total of 1.266s
Component meta_cat.Presence took (min/mean/median/average): 67.763ms / 79.648ms / 79.238ms / 92.354msover 4 docs and a total of 1.266s
Component meta_cat.Subject took (min/mean/median/average): 68.097ms / 82.151ms / 81.284ms / 97.941msover 4 docs and a total of 1.265s
Component meta_cat.Time took (min/mean/median/average): 67.350ms / 82.718ms / 82.588ms / 98.344msover 4 docs and a total of 1.262s
Component tagging:tag-and-skip-tagger took (min/mean/median/average): 0.665ms / 0.840ms / 0.840ms / 1.015msover 2 docs and a total of 0.922s
Component token_normalizing:token_normalizer took (min/mean/median/average): 4.534ms / 5.197ms / 5.197ms / 5.859msover 2 docs and a total of 0.917s
Component ner:cat_ner took (min/mean/median/average): 2.992ms / 3.452ms / 3.452ms / 3.913msover 2 docs and a total of 0.913s
Component linking:medcat2_linker took (min/mean/median/average): 26.527ms / 31.275ms / 31.275ms / 36.022msover 2 docs and a total of 0.878s
Component meta_cat.Presence took (min/mean/median/average): 66.944ms / 78.302ms / 78.302ms / 89.660msover 2 docs and a total of 0.789s
Component meta_cat.Subject took (min/mean/median/average): 67.093ms / 78.330ms / 78.330ms / 89.567msover 2 docs and a total of 0.700s
Component meta_cat.Time took (min/mean/median/average): 67.026ms / 78.276ms / 78.276ms / 89.526msover 2 docs and a total of 0.611s

***Defaults to 100 docs

Component tagging:tag-and-skip-tagger took (min/mean/median/average): 0.637ms / 0.826ms / 0.839ms / 1.022msover 10 docs and a total of 3.113s
Component token_normalizing:token_normalizer took (min/mean/median/average): 4.452ms / 5.531ms / 5.632ms / 8.972msover 10 docs and a total of 3.113s
Component ner:cat_ner took (min/mean/median/average): 2.844ms / 3.554ms / 3.934ms / 4.237msover 10 docs and a total of 3.113s
Component linking:medcat2_linker took (min/mean/median/average): 26.131ms / 30.577ms / 31.229ms / 35.847msover 10 docs and a total of 3.113s
Component meta_cat.Presence took (min/mean/median/average): 66.759ms / 80.231ms / 82.157ms / 103.235msover 10 docs and a total of 3.113s
Component meta_cat.Subject took (min/mean/median/average): 67.315ms / 78.658ms / 79.135ms / 91.097msover 10 docs and a total of 3.113s
Component meta_cat.Time took (min/mean/median/average): 66.791ms / 78.857ms / 79.737ms / 92.347msover 10 docs and a total of 3.113s

***Look at specific component

Component ner:cat_ner profile (by tottime):
        155515 function calls in 0.068 seconds

  Ordered by: internal time
  List reduced from 33 to 20 due to restriction <20>

  ncalls  tottime  percall  cumtime  percall filename:lineno(function)
      10    0.012    0.001    0.068    0.007 /Users/martratas/Documents/CogStack/.MedCAT.nosync/monorepo-nlp/medcat-v2/medcat/components/ner/vocab_based_ner.py:30(predict_entities)
    9195    0.010    0.000    0.010    0.000 /Users/martratas/Documents/CogStack/.MedCAT.nosync/monorepo-nlp/medcat-v2/.venv312/lib/python3.12/site-packages/spacy/tokens/underscore.py:23(__init__)
    5635    0.005    0.000    0.015    0.000 /Users/martratas/Documents/CogStack/.MedCAT.nosync/monorepo-nlp/medcat-v2/medcat/tokenizing/spacy_impl/tokens.py:44(norm)
    9195    0.005    0.000    0.007    0.000 /Users/martratas/Documents/CogStack/.MedCAT.nosync/monorepo-nlp/medcat-v2/.venv312/lib/python3.12/site-packages/spacy/tokens/underscore.py:46(__getattr__)
    8265    0.005    0.000    0.006    0.000 /Users/martratas/Documents/CogStack/.MedCAT.nosync/monorepo-nlp/medcat-v2/medcat/cdb/cdb.py:51(has_subname)
    1585    0.004    0.000    0.010    0.000 /Users/martratas/Documents/CogStack/.MedCAT.nosync/monorepo-nlp/medcat-v2/medcat/components/ner/vocab_based_annotator.py:19(annotate_name)
    1585    0.004    0.000    0.004    0.000 /Users/martratas/Documents/CogStack/.MedCAT.nosync/monorepo-nlp/medcat-v2/medcat/tokenizing/spacy_impl/tokenizers.py:72(create_entity)
    16405    0.003    0.000    0.004    0.000 /Users/martratas/Documents/CogStack/.MedCAT.nosync/monorepo-nlp/medcat-v2/medcat/tokenizing/spacy_impl/tokens.py:52(base)
    3560    0.003    0.000    0.010    0.000 /Users/martratas/Documents/CogStack/.MedCAT.nosync/monorepo-nlp/medcat-v2/medcat/tokenizing/spacy_impl/tokens.py:36(to_skip)
    25330    0.002    0.000    0.002    0.000 {built-in method builtins.len}
    5635    0.002    0.000    0.019    0.000 /Users/martratas/Documents/CogStack/.MedCAT.nosync/monorepo-nlp/medcat-v2/medcat/tokenizing/spacy_impl/tokens.py:60(text_versions)
    5635    0.002    0.000    0.002    0.000 /Users/martratas/Documents/CogStack/.MedCAT.nosync/monorepo-nlp/medcat-v2/medcat/tokenizing/spacy_impl/tokens.py:64(lower)
    3570    0.002    0.000    0.002    0.000 /Users/martratas/Documents/CogStack/.MedCAT.nosync/monorepo-nlp/medcat-v2/medcat/tokenizing/spacy_impl/tokens.py:260(__iter__)
    1585    0.001    0.000    0.012    0.000 /Users/martratas/Documents/CogStack/.MedCAT.nosync/monorepo-nlp/medcat-v2/medcat/components/ner/vocab_based_annotator.py:62(maybe_annotate_name)
    9195    0.001    0.000    0.001    0.000 /Users/martratas/Documents/CogStack/.MedCAT.nosync/monorepo-nlp/medcat-v2/.venv312/lib/python3.12/site-packages/spacy/tokens/underscore.py:92(_get_key)
    17990    0.001    0.000    0.001    0.000 /Users/martratas/.pyenv/versions/3.12.10/lib/python3.12/typing.py:2187(cast)
    9160    0.001    0.000    0.001    0.000 /Users/martratas/Documents/CogStack/.MedCAT.nosync/monorepo-nlp/medcat-v2/medcat/tokenizing/spacy_impl/tokens.py:96(index)
    3170    0.001    0.000    0.001    0.000 /Users/martratas/.pyenv/versions/3.12.10/lib/python3.12/logging/__init__.py:1517(debug)
    4580    0.001    0.000    0.001    0.000 {method 'append' of 'list' objects}
    2640    0.000    0.000    0.000    0.000 {built-in method builtins.isinstance}



Component ner:cat_ner profile (by cumtime):
        155515 function calls in 0.068 seconds

  Ordered by: cumulative time
  List reduced from 33 to 20 due to restriction <20>

  ncalls  tottime  percall  cumtime  percall filename:lineno(function)
      10    0.000    0.000    0.068    0.007 /Users/martratas/Documents/CogStack/.MedCAT.nosync/monorepo-nlp/medcat-v2/medcat/components/types.py:150(__call__)
      10    0.012    0.001    0.068    0.007 /Users/martratas/Documents/CogStack/.MedCAT.nosync/monorepo-nlp/medcat-v2/medcat/components/ner/vocab_based_ner.py:30(predict_entities)
    5635    0.002    0.000    0.019    0.000 /Users/martratas/Documents/CogStack/.MedCAT.nosync/monorepo-nlp/medcat-v2/medcat/tokenizing/spacy_impl/tokens.py:60(text_versions)
    5635    0.005    0.000    0.015    0.000 /Users/martratas/Documents/CogStack/.MedCAT.nosync/monorepo-nlp/medcat-v2/medcat/tokenizing/spacy_impl/tokens.py:44(norm)
    1585    0.001    0.000    0.012    0.000 /Users/martratas/Documents/CogStack/.MedCAT.nosync/monorepo-nlp/medcat-v2/medcat/components/ner/vocab_based_annotator.py:62(maybe_annotate_name)
    1585    0.004    0.000    0.010    0.000 /Users/martratas/Documents/CogStack/.MedCAT.nosync/monorepo-nlp/medcat-v2/medcat/components/ner/vocab_based_annotator.py:19(annotate_name)
    9195    0.010    0.000    0.010    0.000 /Users/martratas/Documents/CogStack/.MedCAT.nosync/monorepo-nlp/medcat-v2/.venv312/lib/python3.12/site-packages/spacy/tokens/underscore.py:23(__init__)
    3560    0.003    0.000    0.010    0.000 /Users/martratas/Documents/CogStack/.MedCAT.nosync/monorepo-nlp/medcat-v2/medcat/tokenizing/spacy_impl/tokens.py:36(to_skip)
    9195    0.005    0.000    0.007    0.000 /Users/martratas/Documents/CogStack/.MedCAT.nosync/monorepo-nlp/medcat-v2/.venv312/lib/python3.12/site-packages/spacy/tokens/underscore.py:46(__getattr__)
    8265    0.005    0.000    0.006    0.000 /Users/martratas/Documents/CogStack/.MedCAT.nosync/monorepo-nlp/medcat-v2/medcat/cdb/cdb.py:51(has_subname)
    16405    0.003    0.000    0.004    0.000 /Users/martratas/Documents/CogStack/.MedCAT.nosync/monorepo-nlp/medcat-v2/medcat/tokenizing/spacy_impl/tokens.py:52(base)
    1585    0.004    0.000    0.004    0.000 /Users/martratas/Documents/CogStack/.MedCAT.nosync/monorepo-nlp/medcat-v2/medcat/tokenizing/spacy_impl/tokenizers.py:72(create_entity)
    25330    0.002    0.000    0.002    0.000 {built-in method builtins.len}
    3570    0.002    0.000    0.002    0.000 /Users/martratas/Documents/CogStack/.MedCAT.nosync/monorepo-nlp/medcat-v2/medcat/tokenizing/spacy_impl/tokens.py:260(__iter__)
    5635    0.002    0.000    0.002    0.000 /Users/martratas/Documents/CogStack/.MedCAT.nosync/monorepo-nlp/medcat-v2/medcat/tokenizing/spacy_impl/tokens.py:64(lower)
    9195    0.001    0.000    0.001    0.000 /Users/martratas/Documents/CogStack/.MedCAT.nosync/monorepo-nlp/medcat-v2/.venv312/lib/python3.12/site-packages/spacy/tokens/underscore.py:92(_get_key)
    17990    0.001    0.000    0.001    0.000 /Users/martratas/.pyenv/versions/3.12.10/lib/python3.12/typing.py:2187(cast)
    3170    0.001    0.000    0.001    0.000 /Users/martratas/.pyenv/versions/3.12.10/lib/python3.12/logging/__init__.py:1517(debug)
    9160    0.001    0.000    0.001    0.000 /Users/martratas/Documents/CogStack/.MedCAT.nosync/monorepo-nlp/medcat-v2/medcat/tokenizing/spacy_impl/tokens.py:96(index)
    4580    0.001    0.000    0.001    0.000 {method 'append' of 'list' objects}

@tomolopolis
Copy link
Copy Markdown
Member

Comment thread medcat-v2/medcat/pipeline/speed_utils.py Outdated
Comment thread medcat-v2/medcat/pipeline/speed_utils.py Outdated
Copy link
Copy Markdown
Collaborator

@alhendrickson alhendrickson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, thanks!

@mart-r mart-r merged commit 79f00cf into main Mar 17, 2026
22 checks passed
@mart-r mart-r deleted the feat/medcat/CU-869cgny1k-add-pipe-speed-options branch March 17, 2026 14:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants