[Etoys] experimental GetTextTranslator

Takashi Yamamiya tak at metatoys.org
Thu Sep 27 14:14:26 EDT 2007


Great!

I takes about 4 seconds in XO machine. Here is the result of
MessageTally spyOn: [GetTextTranslator localeChanged: 'ja']

Cheers,
- Takashi

---

 - 4430 tallies, 4847 msec.

**Tree**
100.0% {4847ms} GetTextTranslator class>>localeChanged:
  100.0% {4847ms} TextDomain>>localeChanged:
    100.0% {4847ms} TextDomain>>loadMOForLocale:
      99.9% {4842ms} MOFile>>load:
        94.0% {4556ms} MOFile>>loadStringTable:
          |81.9% {3970ms} ByteString(String)>>convertFromWithConverter:
          |  |60.0% {2908ms} UTF8TextConverter>>nextFromStream:
          |  |  |39.0% {1890ms} Unicode class>>value:
          |  |  |  |27.7% {1343ms} Locale>>languageEnvironment
          |  |  |  |  |25.7% {1246ms} LanguageEnvironment class>>localeID:
          |  |  |  |  |  22.9% {1110ms} Dictionary>>at:ifAbsent:
          |  |  |  |  |    21.0% {1018ms} Dictionary(Set)>>findElementOrNil:
          |  |  |  |  |      19.9% {965ms} Dictionary>>scanFor:
          |  |  |  |  |        9.8% {475ms} LocaleID>>=
          |  |  |  |  |          |6.9% {334ms} ByteString(String)>>=
          |  |  |  |  |          |  4.9% {238ms} ByteString(String)>>compare:caseSensitive:
          |  |  |  |  |          |    2.8% {136ms} primitives
          |  |  |  |  |          |    2.1% {102ms} ByteString(String)>>compare:with:collated:
          |  |  |  |  |        8.3% {402ms} LocaleID>>hash
          |  |  |  |  |          4.4% {213ms} ByteString(String)>>hash
          |  |  |  |  |            |2.3% {111ms} primitives
          |  |  |  |  |          2.0% {97ms} primitives
          |  |  |  |5.0% {242ms} Character class>>leadingChar:code:
          |  |  |  |  |3.9% {189ms} Character class>>value:
          |  |  |  |  |  2.1% {102ms} Character>>setValue:
          |  |  |  |3.3% {160ms} JapaneseEnvironment(LanguageEnvironment)>>leadingChar
          |  |  |7.9% {383ms} ReadStream(Stream)>>basicNext
          |  |  |  |7.5% {364ms} primitives
          |  |  |4.9% {238ms} ReadStream(PositionableStream)>>isBinary
          |  |  |4.7% {228ms} primitives
          |  |  |3.5% {170ms} Character>>=
          |  |10.7% {519ms} WriteStream>>nextPut:
          |  |  |4.3% {208ms} primitives
          |  |  |3.1% {150ms} Character>>isOctetCharacter
          |  |5.5% {267ms} primitives
          |  |2.2% {107ms} WriteStream>>contents
          |5.5% {267ms} MOFile>>readInt32
          |  4.8% {233ms} MultiByteFileStream(PositionableStream)>>nextLittleEndianNumber:
          |    2.7% {131ms} primitives
          |    2.1% {102ms} MultiByteFileStream>>next:
        3.8% {184ms} Dictionary>>at:put:

**Leaves**
7.5% {364ms} ReadStream(Stream)>>basicNext
5.5% {267ms} ByteString(String)>>convertFromWithConverter:
4.9% {238ms} ReadStream(PositionableStream)>>isBinary
4.7% {228ms} UTF8TextConverter>>nextFromStream:
4.3% {208ms} WriteStream>>nextPut:
4.2% {204ms} UndefinedObject(Object)>>hash
3.5% {170ms} Character>>=
3.1% {150ms} Character>>isOctetCharacter
3.1% {150ms} ByteString(String)>>compare:caseSensitive:
3.0% {145ms} MultiByteFileStream(PositionableStream)>>nextLittleEndianNumber:
3.0% {145ms} Dictionary>>scanFor:
2.4% {116ms} ByteString(String)>>hash
2.4% {116ms} ByteString(String)>>compare:with:collated:
2.3% {111ms} Character>>setValue:
2.2% {107ms} ByteString(String)>>=
2.1% {102ms} SmallInteger(Magnitude)>>max:
2.0% {97ms} LocaleID>>hash

**Memory**
	old			+576,968 bytes
	young		+133,848 bytes
	used		+710,816 bytes
	free		-710,816 bytes

**GCs**
	full			0 totalling 0ms (0.0% uptime)
	incr		81 totalling 189ms (4.0% uptime), avg 2.0ms
	tenures		6 (avg 13 GCs/tenure)
	root table	0 overflows

korakurider at yahoo.co.jp wrote:
> Hello.
> (I am sending off list as this is too half-baking :-)
> 
> First experimental prototype for a simple replacement of 
> NaturalLanguageTranslator is attached.
> 
> -----
> How to run: (assuming language is 'ja')
> 
>     1) prepare etoys.mo
>         (japaense mo is attached also)
>     2) place etoys.mo at place at 
>         %imagePath%/locales/ja/LC_MESSAGES
> 
>     3) starts etoys.image and apply the changeset
>     4) switch current locale to 'japanese'
>     5) doIt: "GetTextTranslator localeChanged: 'ja'",  then mo is loaded
>     6) printIt: "GetTextTranslator translate: 'string' to: 'ja'" returns 
> translation.
> 
> My original plan was to replace method body of #tranlatedTo: as 6), 
> but it doesn't work at this time. (see a in below)
> 
> As you know entire content of MO is loaded to memory in this MOFile 
> implementation.  I was worrying about that performance before this 
> experiment.  Actually I feel it would be usable at least on my PC box 
> (Panasonic CF-W2).  Could you please test it on real XO if you can?
> 
> ------
> Outstanding issues: (Please let me know how do you think)
> 
>     a) to load utf-8 string from MO, correct leadingChar have to 
>         to be determined from locale.
>         (That's why step 4) is needed proceeding to step 5)
>         I know "LanguageEnvironment leadingChar" but I am totally 
> confused with relationship between LanguageEnvironment and Locale...
> 
>     b) where and how to initialize the translator
>        e.g. first call of "GetTextTranslator currentDomain:" and "
> GetTextTranslator localeChanged:"
>        
>     c) monitor actual locale change and handle it
>     d) when and how to release resource to minimize meory foot print.
>     e) what is default domain (currently 'etoys')
>     f) preparation of MOs, ofcourse.
>     g) fallback domain of translation, that Bert suggested
> 
> 
> Cheers,
> 
> /Korakurider



More information about the Etoys mailing list