On 2011/11/09 12:12:53, Yang wrote:
On 2011/10/26 09:43:52, Yang wrote:
> Turns out my changes were not well tested to begin with. I added some tests
and
> fixed the issues.
>
> The null embedding has been fixed by an additional loop doing a replace. It
is
> still faster this way. I gathered some data. Using WriteAscii on a cons with
> length 2^28 and 28 levels, the old version takes 1780ms, the new version
takes
> 1140ms. When using WriteAscii on a cons with length 2^8 and 8 levels a total
of
> 2^20 times, the old version takes 1700ms, the new version takes 990ms.

*gentle nudge*

Ping on this.  This fast path would improve some things for nodejs.

The effectiveness of this patch can be tested with this, appended to test-api.cc

==================
#include <ctime>

TEST(ConsWrite) {
  v8::HandleScope scope;
  LocalContext env;
  v8::Local<v8::Value> result;
  const char* cons = "c = 'a'; for (var i=0; i < 28; i++) c = c+c;";

  v8::Local<v8::String> string = v8::String::Cast(*CompileRun(cons));

  char* buffer = new char[1 << 28];
  clock_t start = clock();
  string->WriteAscii(buffer, 0, (1 << 28) -1);
  clock_t stop = clock();
printf("%f milliseconds\n", (double) (stop - start) / CLOCKS_PER_SEC * 1000);

  start = clock();
  string->WriteAscii(buffer, 0, (1 << 28) -1,
                     v8::String::HINT_MANY_WRITES_EXPECTED);
  stop = clock();
printf("%f milliseconds\n", (double) (stop - start) / CLOCKS_PER_SEC * 1000);
}
==================

The result I get is
- w/o patch

1780.000000 milliseconds
1550.000000 milliseconds

- w/ patch

1180.000000 milliseconds
1220.000000 milliseconds




http://codereview.chromium.org/8390004/

--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev

Reply via email to