Giter Club home page Giter Club logo

Comments (20)

devblackops avatar devblackops commented on June 12, 2024 3

I did a quick experiment with storing the current theme that's saved at $env:APPDATA/powershell/Community/Terminal-Icons/Configuration.psd1 as JSON instead of PSD1. There is a noticeable improvement in module load times by using ConvertTo-Json/ConvertFrom-Json vs Import-Configuration/Export-Configuration for getting/saving the selected theme.

By changing the theme format and removing the dependency on the Configuration module I was able to get module load times down to 360ms vs 1200ms

pwsh -nop -c '(measure-command {ipmo terminal-icons -requiredversion 0.1.1}).TotalMilliseconds'
1290.3601
pwsh -nop -c '(measure-command {ipmo terminal-icons -requiredversion 0.2.0}).TotalMilliseconds'  
361.3216

I'll have to play with this some more to make everything works as expected but on the face of it, I think this is a pretty good improvement.

from terminal-icons.

nstrelow avatar nstrelow commented on June 12, 2024 2

I feel like this is still very slow on startup
Anything to be done about it?

Or maybe the update did not work for me and I need to reset something? I am on 0.2.2

from terminal-icons.

devblackops avatar devblackops commented on June 12, 2024 2

@nstrelow What are the import times you're experiencing?

Also, what is in $env:USERPROFILE/AppData/Roaming/powershell/Community/Terminal-Icons? Do you have theme.xml and nothing else? If there is a psd1 file in there, try removing it or renaming it to a different extension.

from terminal-icons.

devblackops avatar devblackops commented on June 12, 2024 2

Good to hear. Sounds like some logic needs to be updated to not load the psd1 if it exists.

from terminal-icons.

ajhall avatar ajhall commented on June 12, 2024 1

PoshCode/Configuration#39

I made a pull request to the Configuration module with some decent performance improvements. I don't think it'll fix the entire delay on startup, but it definitely helps.

from terminal-icons.

devblackops avatar devblackops commented on June 12, 2024 1

@rashil2000 v0.2.0 has just been released to PSGallery!

from terminal-icons.

rashil2000 avatar rashil2000 commented on June 12, 2024

After a bit of struggle I find out that only 84 of the 3810 glyphs imported were actually being used in devblackops.psd1 file.

Here's the shortened glyphs.ps1 file.

@{
    'nf-fa-folder'                                   = ''
    'nf-mdi-folder_image'                            = ''
    'nf-custom-folder_config'                        = ''
    'nf-custom-folder_git'                           = ''
    'nf-custom-folder_github'                        = ''
    'nf-fa-file'                                     = ''
    'nf-oct-person'                                  = ''
    'nf-seti-json'                                   = ''
    'nf-fa-gitlab'                                   = ''
    'nf-mdi-xml'                                     = '謹'
    'nf-fa-gear'                                     = ''
    'nf-dev-npm'                                     = ''
    'nf-fae-checklist_o'                             = ''
    'nf-dev-bower'                                   = ''
    'nf-dev-travis'                                  = ''
    'nf-fa-file_o'                                   = ''
    'nf-seti-favicon'                                = ''
    'nf-dev-gulp'                                    = ''
    'nf-dev-firebase'                                = ''
    'nf-mdi-library_books'                           = ''
    'nf-mdi-certificate'                             = ''
    'nf-dev-jenkins'                                 = ''
    'nf-dev-docker'                                  = ''
    'nf-mdi-vuejs'                                   = ''
    'nf-dev-bitbucket'                               = ''
    'nf-dev-nodejs_small'                            = ''
    'nf-dev-git'                                     = ''
    'nf-mdi-azure'                                   = ''
    'nf-mdi-check_circle'                            = ''
    'nf-dev-erlang'                                  = ''
    'nf-oct-ruby'                                    = ''
    'nf-dev-javascript'                              = ''
    'nf-mdi-xaml'                                    = ''
    'nf-mdi-file_excel'                              = ''
    'nf-seti-typescript'                             = ''
    'nf-dev-php'                                     = ''
    'nf-dev-sublime'                                 = ''
    'nf-mdi-visualstudio'                            = ''
    'nf-dev-markdown'                                = ''
    'nf-mdi-language_csharp'                         = ''
    'nf-oct-file_zip'                                = ''
    'nf-dev-less'                                    = ''
    'nf-dev-terminal_badge'                          = ''
    'nf-fa-file_video_o'                             = ''
    'nf-fa-certificate'                              = ''
    'nf-seti-html'                                   = ''
    'nf-dev-rust'                                    = ''
    'nf-mdi-language_c'                              = ''
    'nf-dev-sass'                                    = ''
    'nf-oct-terminal'                                = ''
    'nf-fa-lock'                                     = ''
    'nf-dev-visualstudio'                            = ''
    'nf-dev-code_badge'                              = ''
    'nf-mdi-file_pdf'                                = ''
    'nf-mdi-file_word'                               = ''
    'nf-fa-key'                                      = ''
    'nf-mdi-svg'                                     = ''
    'nf-dev-css3'                                    = ''
    'nf-dev-perl'                                    = ''
    'nf-custom-msdos'                                = ''
    'nf-dev-dart'                                    = ''
    'nf-dev-clojure'                                 = ''
    'nf-dev-database'                                = ''
    'nf-mdi-application'                             = ''
    'nf-fa-archive'                                  = ''
    'nf-dev-go'                                      = ''
    'nf-dev-haskell'                                 = ''
    'nf-mdi-file_powerpoint'                         = ''
    'nf-mdi-file_document'                           = ''
    'nf-dev-react'                                   = ''
    'nf-custom-elixir'                               = ''
    'nf-fa-calendar'                                 = ''
    'nf-seti-lua'                                    = ''
    'nf-dev-groovy'                                  = ''
    'nf-dev-fsharp'                                  = ''
    'nf-dev-apple'                                   = ''
    'nf-fa-file_audio_o'                             = ''
    'nf-mdi-help_box'                                = ''
    'nf-mdi-language_cpp'                            = ''
    'nf-fa-file_image_o'                             = ''
    'nf-custom-elm'                                  = ''
    'nf-mdi-format_align_left'                       = ''
    'nf-fa-font'                                     = ''
    'nf-mdi-view_list'                               = ''
}

We can use this. If users want to add more icons to their custom icon themes, they can just append their icons to this file.

from terminal-icons.

devblackops avatar devblackops commented on June 12, 2024

Thanks for the issue @rashil2000. In limited testing on my machine, I see that loading the module and just loading the glyphs in a new PowerShell instance takes the following:

Commands:

pwsh -nop -c '(Measure-Command { Import-Module Terminal-Icons }).TotalMilliseconds'
powershell -nop -c '(Measure-Command { Import-Module Terminal-Icons }).TotalMilliseconds'
pwsh -nop -c '(Measure-Command {$g = . C:\Users\Brandon\Documents\PowerShell\Modules\Terminal-Icons\0.1.1\Data\glyphs.ps1}).TotalMilliseconds'
powershell -nop -c '(Measure-Command {$g = . C:\Users\Brandon\Documents\PowerShell\Modules\Terminal-Icons\0.1.1\Data\glyphs.ps1}).TotalMilliseconds'
Task Pwsh Version Time (ms)
Module import PowerShell 7.0.3 1422.1564
Module import Windows PowerShell 5.1.19041.546 1224.1456
Glyph import PowerShell 7.0.3 50.802
Glyph import Windows PowerShell 5.1.19041.546 38.2479

It doesn't look like loading the glyphs is the primary cause of slow loading. We'll have to dig in a bit more.

from terminal-icons.

rashil2000 avatar rashil2000 commented on June 12, 2024

@devblackops I was about to say this! Perhaps I judged the glyphs.ps1 too quickly. I tested by putting the modified file I mentioned above, and it hadn't affected the import time at all.

There might be something else that's holding this back then, because 1.5-2 seconds is still a lot of time.

from terminal-icons.

ajhall avatar ajhall commented on June 12, 2024

I've noticed this too, and it seems to be something happening inside the Configuration module. These two lines account for most of the slowdown (especially the Export-Configuration line):

$themeData = Import-Configuration

$themeData | Export-Configuration

It seems to do quite a bit of work every time the module is initially imported to import and re-export the Configuration.psd1 file.

from terminal-icons.

rashil2000 avatar rashil2000 commented on June 12, 2024

@ajhall Looks like the repo you sent a PR to hasn't seen a commit in a couple of years. It's no longer maintained :(

Is it possible to bake in the module here itself instead of having a dependency?

from terminal-icons.

ajhall avatar ajhall commented on June 12, 2024

There are a couple quick fixes you could make locally:

  1. You should have a local copy of Metadata.psm1 at ~\Documents\PowerShell\Modules\Configuration\1.3.1\Metadata.psm1 that you can manually edit to apply the change I suggested in the pull request.
  2. If you're fine with the built-in theme, you can edit ~\Documents\PowerShell\Modules\Terminal-Icons\0.1.1\Terminal-Icons.psm1 to comment out the two lines I mentioned in #13 (comment). That will make it skip over the slowest parts entirely.

Anything beyond that might require @devblackops to rework the way this module saves and loads its configuration, so I can't speak to that 😄

from terminal-icons.

devblackops avatar devblackops commented on June 12, 2024

@rashil2000 @ajhall. Can run both try pulling the latest and running .\build.ps1 -task build and testing out 0.2.0 in the output directory? I've decided to use Import/Export-CliXml instead of storing the current theme in JSON. This is so the module will work with < PowerShell 6.0 since ConvertFom-Json -AsHashtable was introduced in 6.0 and I'd like to keep compatibility with other versions.

from terminal-icons.

rashil2000 avatar rashil2000 commented on June 12, 2024

I am getting this error The term 'Set-BuildEnvironment' is not recognized as the name of a cmdlet, function, script file, or operable program. Do I need to install any module for building?

from terminal-icons.

devblackops avatar devblackops commented on June 12, 2024

Yes, the build dependencies. Try:

.\build.ps1 -task build -bootstrap

from terminal-icons.

rashil2000 avatar rashil2000 commented on June 12, 2024

Okay, so I built the module. It's significantly faster now.

PS > (Measure-Command { Import-Module 'C:\Users\RashilGandhi\3D Objects\Terminal-Icons\Output\Terminal-Icons\0.2.0\Terminal-Icons.psd1' }).TotalMilliseconds
1032

from terminal-icons.

ajhall avatar ajhall commented on June 12, 2024

Looks good here too:

❯ (Measure-Command { Import-Module '.\Terminal-Icons.psd1' }).TotalMilliseconds
320.1912

from terminal-icons.

rashil2000 avatar rashil2000 commented on June 12, 2024

@devblackops Is the new (improved) version not going to be released?

from terminal-icons.

devblackops avatar devblackops commented on June 12, 2024

@rashil2000 v0.2.0 has just been released to [PSGallery!

from terminal-icons.

nstrelow avatar nstrelow commented on June 12, 2024

OMG this is so much better.

Terminal starting went down from 2000ms to 1100ms.

Thanks a lot.
Maybe this should be mentioned somewhere, so thst Others also experience the boost :D

Dumb old files laying around.

from terminal-icons.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.