Skip to content

[BUG] Performance of track is significantly worse than spinner #3859

@IgnacioJPickering

Description

@IgnacioJPickering

Describe the bug

track performance is significantly worse than spinner

import time
from rich.progress import track
from rich.console import Console

console = Console()

_start = time.perf_counter()
with console.status("some status", spinner="dots"):
    for _ in range(10_000_000):
        pass
print(f"Time elapsed for spinner: {time.perf_counter() - _start} s", flush=True)

_start = time.perf_counter()
for _ in track(range(10_000_000), transient=True):
    pass
print(f"Time elapsed for track: {time.perf_counter() - _start} s", flush=True)
# In my system this is 3x slower for progress than spinner

I understand there may be performance differences between the two, but such a wide gap makes me suspicious. If you are aware of this performance difference feel free to close the issue.

Platform
Linux, using GNOME Terminal 3.52

                                        Rich features                                         
                                                                                              
    Colors    ✓ 4-bit color                 ▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄ 
              ✓ 8-bit color                 ▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄ 
              ✓ Truecolor (16.7 million)    ▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄ 
              ✓ Dumb terminals              ▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄ 
              ✓ Automatic color conversion  ▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄ 
                                                                                              
    Styles    All ansi styles: bold, dim, italic, underline, strikethrough, reverse, and even 
              blink.                                                                          
                                                                                              
     Text     Word wrap text. Justify left, center, right or full.                            
                                                                                              
              Lorem ipsum dolor    Lorem ipsum dolor   Lorem ipsum dolor Lorem  ipsum   dolor 
              sit amet,                sit amet,               sit amet, sit            amet, 
              consectetur             consectetur            consectetur consectetur          
              adipiscing elit.     adipiscing elit.     adipiscing elit. adipiscing     elit. 
              Quisque in metus     Quisque in metus     Quisque in metus Quisque in metus sed 
              sed sapien              sed sapien              sed sapien sapien     ultricies 
              ultricies pretium a ultricies pretium a  ultricies pretium pretium a at  justo. 
              at justo. Maecenas  at justo. Maecenas         a at justo. Maecenas      luctus 
              luctus velit et       luctus velit et      Maecenas luctus velit   et    auctor 
              auctor maximus.       auctor maximus.      velit et auctor maximus.             
                                                                maximus.                      
                                                                                              
    Asian     🇨🇳  该库支持中文,日文和韩文文本!                                              
   language   🇯🇵  ライブラリは中国語、日本語、韓国語のテキストをサポートしています            
   support    🇰🇷  이 라이브러리는 중국어, 일본어 및 한국어 텍스트를 지원합니다                
                                                                                              
    Markup    Rich supports a simple bbcode-like markup for color, style, and emoji! 👍 🍎  … 
              🐻 🥖 🚌                                                                        
                                                                                              
    Tables     Date           Title                       Production Budget       Box Office  
              ─────────────────────────────────────────────────────────────────────────────── 
               Dec 20, 2019   Star Wars: The Rise of           $275,000,000     $375,126,118  
                              Skywalker                                                       
               May 25, 2018   Solo: A Star Wars Story          $275,000,000     $393,151,347  
               Dec 15, 2017   Star Wars Ep. VIII: The          $262,000,000   $1,332,539,889  
                              Last Jedi                                                       
               May 19, 1999   Star Wars Ep. I: The             $115,000,000   $1,027,044,677  
                              phantom Menace                                                  
                                                                                              
    Syntax       1 def iter_last(values: Iterable[T])  {                                      
 highlighting    2 │   """Iterate and generate a tupl  │   'foo': [                           
      &          3 │   iter_values = iter(values)      │   │   3.1427,                        
    pretty       4 │   try:                            │   │   (                              
   printing      5 │   │   previous_value = next(iter  │   │   │   'Paul Atreides',           
                 6 │   except StopIteration:           │   │   │   'Vladimir Harkonnen',      
                 7 │   │   return                      │   │   │   'Thufir Hawat'             
                 8 │   for value in iter_values:       │   │   )                              
                 9 │   │   yield False, previous_valu  │   ],                                 
                10 │   │   previous_value = value      │   'atomic': (False, True, None)      
                11 │   yield True, previous_value      }                                      
                                                                                              
   Markdown   # Markdown                               ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓ 
                                                       ┃              Markdown              ┃ 
              Supports much of the *markdown*          ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛ 
              __syntax__!                                                                     
                                                       Supports much of the markdown syntax!  
              - Headers                                                                       
              - Basic formatting: **bold**, *italic*,   • Headers                             
              `code`                                    • Basic formatting: bold, italic,     
              - Block quotes                              code                                
              - Lists, and more...                      • Block quotes                        
                                                        • Lists, and more...                  
                                                                                              
    +more!    Progress bars, columns, styled logging handler, tracebacks, etc...              
                                                                                              
rendered in 57.3ms (cold cache)
rendered in 22.6ms (warm cache)


rich @ file:///home/conda/feedstock_root/build_artifacts/bld/rattler-build_rich_1753436991/work/dist

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions