-
<다트> Stopwatch - 함수 호출 완료 시간 검토무기/다트 2023. 4. 8. 21:58728x90
🧭
함수 호출 시간
개발을 하다보면 함수 호출이 완료되기 까지 시간이 얼마나 걸리는지 확인해야 할 필요가 있거나 확인하고 싶을 때가 있습니다.
Stopwatch
이럴 때 사용하는 클래스가 Stopwatch입니다.
바로 사용해 보겠습니다.
void yourFunction() { final stopwatch = Stopwatch()..start(); // something to do... stopwatch.stop(); print('Microseconds:${stopwatch.elapsedMicroseconds}'); }
함수 시작시 stopwatch를 start하고, 종료 직전 stop하면 함수 안에서 시간이 얼마나 소요되는지 확인할 수 있습니다.
📌
https://api.flutter.dev/flutter/dart-core/Stopwatch-class.html
Stopwatch class - dart:core library - Dart API
A stopwatch which measures time while it's running. A stopwatch is either running or stopped. It measures the elapsed time that passes while the stopwatch is running. When a stopwatch is initially created, it is stopped and has measured no elapsed time. Th
api.flutter.dev
728x90'무기 > 다트' 카테고리의 다른 글
[다트] enhanced enum - String 값으로 Enum 값 얻기 (0) 2024.02.17 <다트> removeWhere - 리스트에서 조건을 만족하는 아이템 지우기 (0) 2023.04.08 <다트> == true, == false 사용하지 마세요 (0) 2022.11.17 <Dart> 객체의 DateTime 값을 기준으로 정렬 (0) 2022.10.24 <Dart> getter (0) 2021.07.22