forked from mrousavy/StorageBenchmark
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
98 additions
and
121 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"presets": ["module:metro-react-native-babel-preset"], | ||
"plugins": [ | ||
["@babel/plugin-proposal-decorators", { "legacy": true }] | ||
] | ||
} |
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
This file was deleted.
Oops, something went wrong.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/** | ||
* Sample React Native App | ||
* https://github.com/facebook/react-native | ||
* | ||
* Generated with the TypeScript template | ||
* https://github.com/react-native-community/react-native-template-typescript | ||
* | ||
* @format | ||
*/ | ||
|
||
import React, {useCallback} from 'react'; | ||
import { | ||
Button, | ||
SafeAreaView, | ||
StatusBar, | ||
StyleSheet, | ||
useColorScheme, | ||
} from 'react-native'; | ||
|
||
const App = () => { | ||
const isDarkMode = useColorScheme() === 'dark'; | ||
|
||
const runBenchmarks = useCallback(() => { | ||
console.log('no.'); | ||
}, []); | ||
|
||
return ( | ||
<SafeAreaView style={styles.container}> | ||
<StatusBar barStyle={isDarkMode ? 'light-content' : 'dark-content'} /> | ||
<Button title="Run Benchmarks" onPress={runBenchmarks} /> | ||
</SafeAreaView> | ||
); | ||
}; | ||
|
||
const styles = StyleSheet.create({ | ||
container: {flex: 1, justifyContent: 'center', alignItems: 'center'}, | ||
}); | ||
|
||
export default App; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import AsyncStorage from '@react-native-async-storage/async-storage'; | ||
|
||
const key = 'k'; | ||
|
||
AsyncStorage.setItem(key, 'hello'); | ||
|
||
export async function getFromAsyncStorage(): Promise<string | null> { | ||
return AsyncStorage.getItem(key); | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import {MMKV} from 'react-native-mmkv'; | ||
|
||
const storage = new MMKV(); | ||
const key = 'k'; | ||
storage.set(key, 'hello'); | ||
|
||
export function getFromMMKV(): string | undefined { | ||
return storage.getString(key); | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import 'react-native-quick-sqlite'; | ||
|
||
const db = 'myDatabase'; | ||
|
||
const dbOpenResult = sqlite.open(db, 'databases'); | ||
|
||
// status === 1, operation failed | ||
if (dbOpenResult.status) { | ||
console.error('SQLite Database could not be opened'); | ||
} | ||
|
||
let result = sqlite.executeSql(db, 'DROP TABLE IF EXISTS Values', []); | ||
if (!result.status) { | ||
console.log('Created Table Values'); | ||
} else { | ||
console.error(result); | ||
} | ||
|
||
sqlite.executeSql( | ||
db, | ||
'CREATE TABLE IF NOT EXISTS Values(value VARCHAR(30))', | ||
[], | ||
); | ||
sqlite.executeSql(db, 'INSERT INTO Values (value) VALUES (:value)', ['hello']); | ||
|
||
export function getFromSQLite(): string | undefined { | ||
let {status, rows} = sqlite.executeSql(db, 'SELECT * FROM `values`', []); | ||
if (rows == null || rows.length < 1) { | ||
throw new Error(`Failed to get Values! ${JSON.stringify(status)}`); | ||
} | ||
|
||
return rows.item(0); | ||
} |