Re: А вот, какие итоги получились у мен
Yury Kopyl
hrg на sama.ru
Сб Сен 27 19:08:59 CDT 2003
Greg Belenky -> "А вот, какие итоги получились у меня..." :
GB> Текст идентичный. Присланный Данилом. Для чичтоты эксперимента
GB> возвращается функцией, чтобы тестируемые не могли на него повлиять.
GB> Ширина - 50 символов.
GB> Benchmark: timing 5000 iterations of eugene, greg, hrg, lavei,
GB> marchenko...
GB> eugene: 6 wallclock secs ( 5.65 usr + 0.04 sys = 5.69 CPU) @
GB> 878.73/s (n=5000)
GB> greg: 6 wallclock secs ( 6.22 usr + 0.00 sys = 6.22 CPU) @
GB> 803.86/s (n=5000)
GB> hrg: 2 wallclock secs ( 1.54 usr + 0.00 sys = 1.54 CPU) @
GB> 3246.75/s (n=5000)
GB> lavei: 1 wallclock secs ( 1.53 usr + 0.01 sys = 1.54 CPU) @
GB> 3246.75/s (n=5000)
GB> marchenko: 11 wallclock secs (10.74 usr + 0.03 sys = 10.77 CPU) @
GB> 464.25/s (n=5000)
GB> Rate marchenko greg eugene hrg lavei
GB> marchenko 464/s -- -42% -47% -86% -86%
GB> greg 804/s 73% -- -9% -75% -75%
GB> eugene 879/s 89% 9% -- -73% -73%
GB> hrg 3247/s 599% 304% 269% -- -0%
GB> lavei 3247/s 599% 304% 269% 0% --
GB> А теперь посмотрим, что же на самом деле выдают наши алгоритмы...
GB> (следующие 2 строки я нарисовал прям в постинге, чтобы можно было
GB> оценить попадание в 50-символьную границу...
GB> 10 20 30 40 50
GB> 123456789|123456789|123456789|123456789|123456789|
GB> --------------------------------------------------
GB> lavei---------------------------------------------
GB> A simple, easy to remember system for encoding integer
GB> amounts can be veryuseful. For example, dealers at flea markets
GB> put the information about an itemon a card that they let
GB> potential buyers see. They find it advantageous toencode the amount
GB> they originally paid for the item on the card.A good systemis to
GB> use a substitution code, in which each digit is encoded by a
GB> letter. Aneasy to remember 10-letter word or phrase, the key,
GB> is chosen. Every '1' in thevalue is replaced by the first
GB> letter of the key, every '2' is replaced by thesecond letter of
GB> the key, and so on. Every '0'
GB> is replaced by the last letter ofthe key. Letters that do
GB> not appear in the key can be inserted anywhere withoutaffecting the
GB> value represented by the code.. This helps to make the
GB> resultingcode much harder to break (without knowing the
GB> key).Create a class Substitutethat contains the method getValue
GB> that is given the Strings key and code asinput and that
GB> returns the decoded
GB> hrg-----------------------------------------------
GB> A simple, easy to remember system for encoding
GB> integer amounts can be very useful.
GB> For example, dealers at flea markets put
GB> the information about an item on a card
GB> that they let potential buyers see. They
GB> find it advantageous to
GB> encode the amount they originally paid for the
GB> item on the card.
GB> A good system is to use a
GB> substitution code, in which each digit
GB> is encoded by a letter. An easy to
GB> remember 10-letter word or phrase, the
GB> key, is chosen. Every '1' in the value is
GB> replaced by the first letter of the key,
GB> every '2' is replaced by the second
GB> letter of the key, and so on. Every '0' is
GB> replaced by the last letter of the key.
GB> Letters that do not appear in the key can
GB> be inserted anywhere without affecting the
GB> value represented by the code.. This
GB> helps to make the resulting code
GB> much harder to break (without knowing the
GB> key).
GB> Create a class Substitute that contains
GB> the method getValue that is given
GB> the
GB> Strings key and code as input
GB> and that returns the decoded value.
GB> greg----------------------------------------------
GB> A simple, easy to remember system for encoding integer amounts
GB> can be very useful. For example, dealers at flea markets put the
GB> information about an item on a card that they let potential buyers
GB> see. They find it advantageous to encode the amount they
GB> originally paid for the item on the card. A good system is to use a
GB> substitution code, in which each digit is encoded by a letter.
GB> An easy to remember 10-letter word or phrase, the key, is
GB> chosen. Every '1' in the value is replaced by the first letter
GB> of the key, every '2' is replaced by the second letter of the
GB> key, and so on. Every '0' is replaced by the last letter of the
GB> key. Letters that do not appear in the key can be inserted
GB> anywhere without affecting the value represented by the code..
GB> This helps to make the resulting code much harder to break
GB> (without knowing the key). Create a class Substitute that contains
GB> the method getValue that is given the
GB> Strings key and code as input and that returns the decoded value.
GB> eugene--------------------------------------------
GB> A simple, easy to remember system for encoding integer amounts
GB> can be very useful. For example, dealers at flea markets put the
GB> information about an item on a card that they let potential
GB> buyers see. They find it advantageous to encode the amount
GB> they originally paid for the item on the card. A good system is
GB> to use a substitution code, in which each digit is encoded by a
GB> letter. An easy to remember 10-letter word or phrase, the key,
GB> is chosen. Every '1' in the value is replaced by the first letter
GB> of the key, every '2' is replaced by the second letter of the
GB> key, and so on. Every '0' is replaced by the last letter of the
GB> key. Letters that do not appear in the key can be inserted
GB> anywhere without affecting the value represented by the code..
GB> This helps to make the resulting code much harder to break
GB> (without knowing the key). Create a class Substitute that
GB> contains the method getValue that is given the
GB> Strings key and code as input and that returns the decoded
GB> value marchenko-----------------------------------------
GB> Asimple,easytoremembersystemforencodinginteger
GB> amountscanbeveryuseful.Forexample,dealersatflea
GB> marketsputthe informationaboutanitemonacardthattheyletpotential
GB> buyerssee.Theyfindit
GB> advantageoustoencodetheamounttheyoriginallypaid
GB> fortheitemonthe card.Agoodsystemistouseasubstitutioncode,inwhich
GB> eachdigitis encodedbyaletter.Aneasytoremember10-letterwordor
GB> phrase,thekey,is chosen.Every'1'inthevalueisreplacedbythefirst
GB> letterofthekey,every
GB> '2'isreplacedbythesecondletterofthekey,andsoon.
GB> Every'0'isreplaced
GB> bythelastletterofthekey.Lettersthatdonotappearin
GB> thekeycanbe insertedanywherewithoutaffectingthevalue
GB> representedbythecode..Thishelps
GB> tomaketheresultingcodemuchhardertobreak(without
GB> knowingthe key).CreateaclassSubstitutethatcontainsthemethod
GB> getValuethatisgiventhe
GB> Stringskeyandcodeasinputandthatreturnsthedecoded
GB> value.
GB> --------------------------------------------------
Насчет правильности:
Почти все алгоритмы не учитывают переносы строк в исходном тексте, вернее
они просто заменяют их на пробелы, склеиваяя строку. Это не правильно.
Поробуйте потестить на реальных текстах.
Yury Kopyl aka hrg | http://id.totem.ru | "Сегодня с нами ты не пьешь, а
завтра Родине изменишь!"
Подробная информация о списке рассылки Samara-pm