docsのline_profilerに続いて、自分のコードをプロファイルすることはできますが、出力をpython -m line_profiler script_to_profile.py.lprof
と見ると27行しか表示されません。私は約250を見ると予想しています。なぜなら、それは私が@profile
デコレータを追加した関数の長さなのですから。私の出力は次のようになります:line_profilerは少数の行しか表示していません
Timer unit: 1e-06 s
Total time: 831.023 s
File: /Users/will/Repos/Beyond12/src/student_table.py
Function: aggregate_student_data at line 191
Line # Hits Time Per Hit % Time Line Contents
==============================================================
191 # load files
192 files = os.listdir(datadir)
193
194 tabs = ['Contact', 'Costs_Contributions', 'Course', 'EducationalHistory', 'Events', 'FinancialAidScholarship',
195 1 764 764.0 0.0 'PreCollegiateExam', 'QualitativeInformation', 'Student_Performance', 'Task', 'Term']
196 special_contact_id = {'Contact': 'Id',
197 1 7 7.0 0.0 'Events': 'WhoId',
198 1 6 6.0 0.0 'QualitativeInformation': 'Alumni',
199 1 6 6.0 0.0 'Student_Performance': 'Contact',
200 1 6 6.0 0.0 'PreCollegiateExam': 'Contact ID'}
201 1 6 6.0 0.0
202 1 5 5.0 0.0 # todo: make dictionary of the columns that we'll be using, along with their types?
203
204 df = {}
205 for tab in tabs:
206 1 6 6.0 0.0 # match tab titles to files by matching first 5 non-underscore characters
207 12 115 9.6 0.0 filename = filter(lambda x: tab.replace('_', '')[:5] in x.replace('_', '')[:5], files)[0]
forループの途中で途切れてしまいます。
いくつかの他のコードを拾っているようです。通常、forループはn + 1回実行されます。あなたは[mcve]を作ることを試みることができますか?それはあなたを助けることをより容易にするでしょう。 – MSeifert