0

I run visual studio code on Windows 10. Current version of my visual studio code is 1.45.1. I am running a Python (version 3.7.4 64-bit) on it. My visual studio code takes 5 to 10 minutes to load following libraries:

import pandas as pd
import numpy as np
from datetime import datetime, date
from scipy.stats import ttest_ind
from scipy.stats import ttest_ind_from_stats
from scipy.stats import ttest_1samp
import seaborn as sns
import matplotlib.pyplot as plt

I tried to find a solution online to speed up, but couldn't find it. Is anyone experience the same issue? How could we speed up the visual code?

user2293224
  • 2,128
  • 5
  • 28
  • 52
  • Do you suspect any of these modules specifically? What is `import_datasets `? It does not look like a standard module to me. – DYZ Jun 01 '20 at 21:43
  • It was working fine yesterday. It was bit lagging but today its super slow. I removed the import_datasets but it did not make any difference. – user2293224 Jun 01 '20 at 21:44
  • 2
    How quickly does this Python script take to import everything when run outside of VS Code? If you quit and restart VS Code does it make a difference? – jarmod Jun 01 '20 at 21:45
  • I ran the code on jupyter notebook. It took almost same amount of time to load up the libraries. I restarted the visual code and machine but did not make any difference. – user2293224 Jun 01 '20 at 21:56
  • 1
    You can easily time how long each import takes by printing out the current time between each import statement. That will help you identify the problem. – jarmod Jun 01 '20 at 22:16
  • "*I ran the code on jupyter notebook. It took almost same amount of time to load up the libraries.*" If it's slow even outside VS Code, then it's probably not a VS Code problem. – Gino Mempin Jun 02 '20 at 00:09
  • 1
    Which language server are you using? Jedi or Microsoft? Have you tried both of them? – Brett Cannon Jun 02 '20 at 22:00

1 Answers1

0
from time import perf_counter
a=perf_counter()
import pandas as pd
b=perf_counter()
import numpy as np
c=perf_counter()
from datetime import datetime, date
d=perf_counter()
from scipy.stats import ttest_ind
e=perf_counter()
from scipy.stats import ttest_ind_from_stats
f=perf_counter()
from scipy.stats import ttest_1samp
g=perf_counter()
import seaborn as sns
h=perf_counter()
import matplotlib.pyplot as plt
i=perf_counter()

print(b-a)
print(c-b)
print(d-c)
print(e-d)
print(f-e)
print(g-f)
print(h-g)
print(i-h)

Take this to analyze which imports take too much time.

Then take 'cProfile' to do exactly analysis. you can refer to this page.

Steven-MSFT
  • 7,438
  • 1
  • 5
  • 13