Skip to content

Performance? #15

@sleeyax

Description

@sleeyax

What's the performance of this library? Do you plan to add any benchmarks?

On first sight there appears to be a longer startup time with this library vs a custom platform-specific implementation, but maybe I'm doing something wrong. Thus, some more information about performance would clear things up for me (and many others)!

Click to see example

Example custom implementation w/o this lib

This is what my setup looked like without this library.

commonMain/.../L18n.kt:

@Composable
@ReadOnlyComposable
expect fun translate(key: String): String

androidMain/.../L18n.kt:

package com.example.common.platform

import androidx.compose.runtime.Composable
import androidx.compose.runtime.ReadOnlyComposable
import androidx.compose.ui.res.stringResource
import com.example.common.R

@ReadOnlyComposable
@Composable
actual fun translate(key: String): String {
    val stringClass = R.string::class.java
    val field = stringClass.getDeclaredField(key)
    return stringResource(field.get(stringClass) as Int)
}

iosMain/.../L18n.kt:

Not implemented yet, but same principle

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions