Last active
April 16, 2023 06:19
-
-
Save hardikm9850/52fe702c33f0b49e61a5c3cc20969676 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'dart:math'; | |
void main() async { | |
var duration = _runCPUBoundTask(); | |
print('The duration for CPU bound task is $duration'); | |
} | |
Future<Duration> _runCPUBoundTask() async { | |
var startTime = DateTime.now(); | |
print('Starting ...'); | |
for (var i = 0; i < 1000000000; i++) { | |
sin(cos(tan(sin(cos(tan(sin(cos(tan(sin(123456789.123456789)))))))))); | |
} | |
return DateTime.now().difference(startTime); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment