Git Product home page Git Product logo

Comments (5)

trungdq88 avatar trungdq88 commented on May 21, 2024 1

I will create an issue on prettier as well. prettier/prettier#3386

from vim-prettier.

mitermayer avatar mitermayer commented on May 21, 2024

Hi @trungdq88,

Thanks for raising that, the reason why it may seem slower is that the command you are comparing it to is not the same command that vim-prettier executes over prettier you can see it in here (https://github.com/prettier/vim-prettier/blob/master/autoload/prettier.vim#L240).

Could you try running the same command on the command line ? intead of your example prettier --write app.js try:

cat app.js | prettier --print-width 80 --tab-width 2 --use-tabs false --semi true --single-quote true --bracket-spacing false --jsx-bracket-same-line true --trailing-comma all --parser flow --config-precedence prefer-file --stdin-filepath app.js --stdin

I have a feeling what is causing it to be slow will be some of the arguments passed to prettier itself, probably either --stdin-filepath or --config-precedence.

Please note you can also test this assumption by calling prettier CLI from vim directly and profiling that like:

:PrettierCli --write app.js

Will close this issue now but please comment in here your findings and if that is something related to vim-prettier itself I will make sure to work into fixing it. If its realted to prettier itself I may also be able to contribute a fix back to prettier.

Once again thank you for reporting this issue and looking forward to know a bit more about your findings!

from vim-prettier.

mitermayer avatar mitermayer commented on May 21, 2024

I have also just tested it locally and confirmed this is prettier related.

Check this:

mitermayer@primus ~/temp $ time cat app.js | prettier --print-width 80 --tab-width 2 --use-tabs false --semi true --single-quote true --bracket-spacing false --jsx-bracket-same-line true --trailing-comma all --parser flow --config-precedence prefer-file --stdin-filepath app.js --stdin
const a = 1;

real	0m1.150s
user	0m1.055s
sys	0m0.113s

compared to:

mitermayer@primus ~/temp $ time prettier app.js 
const a = 1;

real	0m1.081s
user	0m1.014s
sys	0m0.070s

I don't have time right now to dig in on what exactly from that command is causing prettier to behave slower, but if you can find it out I should be able to then work on something prettier main repo itself to mitigate it

from vim-prettier.

mitermayer avatar mitermayer commented on May 21, 2024

Also worth testing this out with different versions of prettier as this could also be some performance regressions by prettier itself creating new features

from vim-prettier.

trungdq88 avatar trungdq88 commented on May 21, 2024

prettier reported the task took 44ms. But the actual time prettier app.js took ~1s. This is might have something to do with the "bootstrap time" of prettier.

Is it possible to run something like a "daemon" or "prettier server" to "bootstrap" prettier only once?

from vim-prettier.

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.