Skip to content

Instantly share code, notes, and snippets.

@hardikm9850
Last active April 16, 2023 06:19
Show Gist options
  • Save hardikm9850/52fe702c33f0b49e61a5c3cc20969676 to your computer and use it in GitHub Desktop.
Save hardikm9850/52fe702c33f0b49e61a5c3cc20969676 to your computer and use it in GitHub Desktop.
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