Created
May 31, 2020 16:44
-
-
Save arnold-parge/429906af26b47b46564eba85a85ed3a7 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
static Future initialDownload() async { | |
var response = await AppApi.get<Map<String, dynamic>>(AppUrls.getUsers); | |
if (response.statusCode == 200) { | |
List data = response.data['results']; | |
var saveStartTime = DateTime.now().millisecondsSinceEpoch; | |
for (var rawUser in data) { | |
var user = UserModel.fromMap(rawUser); | |
await AppSqliteDb.sqliteDb.insert(UserModel.tableName, user.toDb()); | |
} | |
var saveEndTime = DateTime.now().millisecondsSinceEpoch; | |
appWarning( | |
'Time taken to save 1000 users to db: ${saveEndTime - saveStartTime}ms'); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment