Skip to content

Instantly share code, notes, and snippets.

View victorers1's full-sized avatar
➡️
If you never try, you'll never catch

Victor Emanuel victorers1

➡️
If you never try, you'll never catch
View GitHub Profile
@victorers1
victorers1 / mixin_basic_usage.dart
Created December 11, 2022 19:18
Studies about Dart mixins
void main() {
final b = Bird();
print('$b is ${b.fly()}');
print('$b is ${b.peck()}');
}
class Bird with Peck {
String fly() => 'flying';
}
@victorers1
victorers1 / datetime_stream.dart
Last active December 11, 2022 18:14
Studying Streams in Dart language
import 'dart:async';
class DateTimeGenerator {
DateTimeGenerator() {
final tenSecsAfterNow = DateTime.now().add(Duration(seconds: 10));
// timer with 10 secs lifetime
Timer.periodic(Duration(seconds: 1), (t) {
_date = _date.add(Duration(seconds: 1));
_controller.sink.add(_date);
@victorers1
victorers1 / future_any.dart
Last active May 28, 2022 20:06
Studying Future in Dart language
void main() async {
/// Both functions init at the same time, Future.any() will return the first one available
final dynamic firstResult = await Future.any([asyncF(), asyncG()]);
/// firstResult can be an integer or a string, thus the 'dynamic' type.
print('$firstResult. Returned value is a ${firstResult.runtimeType}');
}
Future<int> asyncF() async {
print('asyncF init');

SIMLARGE

  • native: 3,500 image queries
  • database with 59,695 images
  • find top 50 images

NATIVE 1 CPU

QUERY TIME: 423.687 seconds

real 7m3.922s

SIMLARGE

  • 256 image queries
  • database with 34,973 images
  • find top 10 images

SIMLARGE 1 CPU

QUERY TIME: 5.984 seconds

real 0m6.169s

SIMLARGE

  • native: 3,500 image queries
  • database with 59,695 images
  • find top 50 images

NATIVE 1 CPU

QUERY TIME: 428.843 seconds

real 7m9.802s

SIMLARGE

  • 256 image queries
  • database with 34,973 images
  • find top 10 images

SIMLARGE 1 CPU

QUERY TIME: 5.965 seconds

real 0m6.073s