<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How can make JSL read binary files faster? in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/How-can-make-JSL-read-binary-files-faster/m-p/829681#M101205</link>
    <description>&lt;P&gt;OK&lt;/P&gt;&lt;P&gt;Thank Craige!&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="2025-01-30_20-16-46.png" style="width: 927px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/72360i19CD85C23D1E72E8/image-size/large?v=v2&amp;amp;px=999" role="button" title="2025-01-30_20-16-46.png" alt="2025-01-30_20-16-46.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 30 Jan 2025 12:18:57 GMT</pubDate>
    <dc:creator>lala</dc:creator>
    <dc:date>2025-01-30T12:18:57Z</dc:date>
    <item>
      <title>How can make JSL read binary files faster?</title>
      <link>https://community.jmp.com/t5/Discussions/How-can-make-JSL-read-binary-files-faster/m-p/829239#M101119</link>
      <description>&lt;P&gt;A binary file has a tabular data.&lt;BR /&gt;It has 144 bytes per line,&lt;BR /&gt;The first column is an 8-byte millisecond timestamp,&lt;BR /&gt;Each subsequent column is split by 4 bytes.&lt;BR /&gt;The key is that the following is only to extract the data of some columns.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="2025-01-27_13-24-46.png" style="width: 999px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/72278i655627DA59353FAD/image-size/large?v=v2&amp;amp;px=999" role="button" title="2025-01-27_13-24-46.png" alt="2025-01-27_13-24-46.png" /&gt;&lt;/span&gt;&lt;BR /&gt;I wrote a JSL that can read data, but it is slower.&lt;BR /&gt;Ask an expert to help fix it.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;co = 144;
bb = Load Text File( file, blob() );
gs = 9;
m = 0;
g = 1;
k = 1;
ar = [];
ar = J( z, g + gs, . );//20230815
For( k = 1, k &amp;lt;= z, k++,
	ff = Blob Peek( bb, (k - 1) * co + 0, 8 );
	a = "";
	Try( a = Blob To Matrix( ff, "uint", 8, "little", 8 )[1] );
	no = Length( Char( a ) );
	If( no &amp;gt; 0,
		Try(
			nn = Format( a / 1000 + Informat( "01/01/1970", "mm/dd/yyyy" ) + In Hours( 8 ), "yyyy-mm-ddThh:mm:ss" );
			b = Num( Munger( nn, 12, 2 ) || Munger( nn, 15, 2 ) || Munger( nn, 18, 2 ) );
		);
		If( 91500 &amp;lt;= b &amp;lt; 92600,
			m = m + 1;
			ar[m, 1] = Num( Munger( nn, 1, 4 ) || Munger( nn, 6, 2 ) || Munger( nn, 9, 2 ) );
			ar[m, 2] = b;

			i = 1;
			ff = Blob Peek( bb, (k - 1) * co + 64, 4 );
			ar[m, g + 2] = Blob To Matrix( ff, "int", 4, "little", 1 )[1] / 1000/*BM1*/;
			i = 1;
			ff = Blob Peek( bb, (k - 1) * co + 68, 4 );
			ar[m, g + 3] = Blob To Matrix( ff, "int", 4, "little", 1 )[1] / 1000/*BM2*/;
			i = 1;
			ff = Blob Peek( bb, (k - 1) * co + 84, 4 );
			ar[m, g + 4] = Blob To Matrix( ff, "int", 4, "little", 1 )[1]/*BL1*/;
			i = 1;
			ff = Blob Peek( bb, (k - 1) * co + 88, 4 );
			ar[m, g + 5] = Blob To Matrix( ff, "int", 4, "little", 1 )[1]/*BL2*/;
			i = 1;
			ff = Blob Peek( bb, (k - 1) * co + 104, 4 );
			ar[m, g + 6] = Blob To Matrix( ff, "int", 4, "little", 1 )[1] / 1000/*MM1*/;
			i = 1;
			ff = Blob Peek( bb, (k - 1) * co + 108, 4 );
			ar[m, g + 7] = Blob To Matrix( ff, "int", 4, "little", 1 )[1] / 1000/*MM2*/;
			i = 1;
			ff = Blob Peek( bb, (k - 1) * co + 124, 4 );
			ar[m, g + 8] = Blob To Matrix( ff, "int", 4, "little", 1 )[1]/*ML1*/;
			i = 1;
			ff = Blob Peek( bb, (k - 1) * co + 128, 4 );
			ar[m, g + 9] = Blob To Matrix( ff, "int", 4, "little", 1 )[1]/*ML2*/;
		);
	,
		Break()
	);
);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Thanks Experts!&lt;/P&gt;</description>
      <pubDate>Mon, 27 Jan 2025 06:47:39 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-can-make-JSL-read-binary-files-faster/m-p/829239#M101119</guid>
      <dc:creator>lala</dc:creator>
      <dc:date>2025-01-27T06:47:39Z</dc:date>
    </item>
    <item>
      <title>Re: How can make JSL read binary files faster?</title>
      <link>https://community.jmp.com/t5/Discussions/How-can-make-JSL-read-binary-files-faster/m-p/829249#M101120</link>
      <description>&lt;P&gt;file&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 27 Jan 2025 06:45:22 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-can-make-JSL-read-binary-files-faster/m-p/829249#M101120</guid>
      <dc:creator>lala</dc:creator>
      <dc:date>2025-01-27T06:45:22Z</dc:date>
    </item>
    <item>
      <title>Re: How can make JSL read binary files faster?</title>
      <link>https://community.jmp.com/t5/Discussions/How-can-make-JSL-read-binary-files-faster/m-p/829522#M101165</link>
      <description>&lt;P&gt;What is faster? How fast it should be?&lt;/P&gt;</description>
      <pubDate>Tue, 28 Jan 2025 16:48:51 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-can-make-JSL-read-binary-files-faster/m-p/829522#M101165</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2025-01-28T16:48:51Z</dc:date>
    </item>
    <item>
      <title>Re: How can make JSL read binary files faster?</title>
      <link>https://community.jmp.com/t5/Discussions/How-can-make-JSL-read-binary-files-faster/m-p/829569#M101174</link>
      <description>&lt;P&gt;Use the JSL profiler to find the hotspots.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The profiler will probably show the blobpeek and blobtomatrix functions very bright red. It looks like they are called millions of times for 4-byte blobs. &lt;/P&gt;
&lt;P&gt;Try this instead: make one giant blobtomatrix call to convert the entire file into four-byte integers. That should be only a few seconds. Use JMP's matrix operations to take the data you need from that.You can probably do the entire conversion without any for-loops.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If needed, you can make another giant matrix of 4- or 8- byte ints, uints, floats. Only use the columns that have the correct binary data. I'd probably just combine two 4-byte ints to make the 8-byte value, something like x[row,1] + ( x[row,2]*(2^32) ).&amp;nbsp; I did not study what you were doing with them, so that might not be what you need.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also: when you use blobtomatrix for 8-byte integers, JMP will only be able to keep 52 of the 64 bits. Since columns 6 and 7 are zero and are the high bits in a 8-byte little-endian number, it will probably work out OK. (a double precision floating point number only has 52 bits of fraction.)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 29 Jan 2025 03:42:26 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-can-make-JSL-read-binary-files-faster/m-p/829569#M101174</guid>
      <dc:creator>Craige_Hales</dc:creator>
      <dc:date>2025-01-29T03:42:26Z</dc:date>
    </item>
    <item>
      <title>Re: How can make JSL read binary files faster?</title>
      <link>https://community.jmp.com/t5/Discussions/How-can-make-JSL-read-binary-files-faster/m-p/829585#M101177</link>
      <description>&lt;P&gt;Thank Craige!&lt;/P&gt;&lt;P class=""&gt;&lt;SPAN class=""&gt;Because the data at the beginning of the file is incomplete, I took the contents of the last line&lt;/SPAN&gt;&lt;/P&gt;&lt;P class=""&gt;&lt;SPAN class=""&gt;This code is used for two splits and two blobs To Matrix&lt;/SPAN&gt;&lt;/P&gt;&lt;P class=""&gt;&lt;SPAN class=""&gt;I guess so.&lt;/SPAN&gt;&lt;/P&gt;&lt;P class=""&gt;&amp;nbsp;&lt;/P&gt;&lt;P class=""&gt;&lt;SPAN class=""&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="2025-01-28_17-03-43.png" style="width: 999px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/72338i6D61BE8FD8E34615/image-size/large?v=v2&amp;amp;px=999" role="button" title="2025-01-28_17-03-43.png" alt="2025-01-28_17-03-43.png" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="2025-01-29_14-38-03.png" style="width: 926px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/72337i65524A98A5F133A1/image-size/large?v=v2&amp;amp;px=999" role="button" title="2025-01-29_14-38-03.png" alt="2025-01-29_14-38-03.png" /&gt;&lt;/span&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 29 Jan 2025 06:43:20 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-can-make-JSL-read-binary-files-faster/m-p/829585#M101177</guid>
      <dc:creator>lala</dc:creator>
      <dc:date>2025-01-29T06:43:20Z</dc:date>
    </item>
    <item>
      <title>Re: How can make JSL read binary files faster?</title>
      <link>https://community.jmp.com/t5/Discussions/How-can-make-JSL-read-binary-files-faster/m-p/829586#M101178</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;pa = "I:\E\20250127.dat";bb = Load Text File( pa, blob() );
co = 144;gs = 9;m = 0;g = 1;k = 1;z0 = Length( bb );z = z0 / co;ar = [];ar = J( z, g + gs, . );
For( k = 1, k &amp;lt;= z, k++,
	ff = Blob Peek( bb, (k - 1) * co + 0, 8 );
	a = Blob To Matrix( ff, "uint", 8, "little", 8 )[1];
	nn = Format( a / 1000 + Informat( "01/01/1970", "mm/dd/yyyy" ) + In Hours( 8 ), "yyyy-mm-ddThh:mm:ss" );
	b = Num( Munger( nn, 12, 2 ) || Munger( nn, 15, 2 ) || Munger( nn, 18, 2 ) );
	m = m + 1;
	ar[m, 1] = Num( Munger( nn, 1, 4 ) || Munger( nn, 6, 2 ) || Munger( nn, 9, 2 ) );
	ar[m, 2] = b;
	ff = Blob Peek( bb, (k - 1) * co + 8, 144 );
	br = Blob To Matrix( ff, "uint", 4, "little", 34 )[0, 1 :: 34];
	z1 = Length( bb );
	z2 = (z1 - 8)&lt;/img&gt; / 4;
	ar[m, g + 2] = br[1, 15] / 1000;
	ar[m, g + 3] = br[1, 16] / 1000;
	ar[m, g + 4] = br[1, 20];
	ar[m, g + 5] = br[1, 21];
	ar[m, g + 6] = br[1, 25] / 1000;
	ar[m, g + 7] = br[1, 26] / 1000;
	ar[m, g + 8] = br[1, 30];
	ar[m, g + 9] = br[1, 31];
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 29 Jan 2025 06:44:33 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-can-make-JSL-read-binary-files-faster/m-p/829586#M101178</guid>
      <dc:creator>lala</dc:creator>
      <dc:date>2025-01-29T06:44:33Z</dc:date>
    </item>
    <item>
      <title>Re: How can make JSL read binary files faster?</title>
      <link>https://community.jmp.com/t5/Discussions/How-can-make-JSL-read-binary-files-faster/m-p/829681#M101205</link>
      <description>&lt;P&gt;OK&lt;/P&gt;&lt;P&gt;Thank Craige!&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="2025-01-30_20-16-46.png" style="width: 927px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/72360i19CD85C23D1E72E8/image-size/large?v=v2&amp;amp;px=999" role="button" title="2025-01-30_20-16-46.png" alt="2025-01-30_20-16-46.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 30 Jan 2025 12:18:57 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-can-make-JSL-read-binary-files-faster/m-p/829681#M101205</guid>
      <dc:creator>lala</dc:creator>
      <dc:date>2025-01-30T12:18:57Z</dc:date>
    </item>
    <item>
      <title>Re: How can make JSL read binary files faster?</title>
      <link>https://community.jmp.com/t5/Discussions/How-can-make-JSL-read-binary-files-faster/m-p/829878#M101222</link>
      <description>&lt;P&gt;Nice! I bet it was a lot faster too! Not a single loop in JSL, all the looping is internal in C++ where it is fast.&lt;/P&gt;
&lt;P&gt;For anyone looking and wondering:&lt;/P&gt;
&lt;P&gt;2: reads the entire file into a blob.&lt;/P&gt;
&lt;P&gt;3: converts the entire blob into a matrix. In particular, the matrix has 36 columns from the original binary data that had 144 bytes per line; the values are all 4-byte integers. 144/4=36.&lt;/P&gt;
&lt;P&gt;4: z appears unused; I *think* it may be ~20 million.&lt;/P&gt;
&lt;P&gt;5-16: makes the data table columns.&lt;/P&gt;
&lt;P&gt;18-19: these innocent-looking statements statements are grabbing tall columns of data from the matrix.&lt;/P&gt;
&lt;P&gt;20: attempts to make a 64-bit integer from two 32-bit integers, see comments previously about 52 bits. Again, this is an entire column in one step.&lt;/P&gt;
&lt;P&gt;21-30: copy and transform entire columns from the matrix to the table.&lt;/P&gt;
&lt;P&gt;This is pretty cool because there are no floating point or text values in the data. Floats could be handled with a second matrix of float 4 or 8. Text is harder but still possible; different choices depending on 7-bit, 8-bit, Unicode character sets and fixed length or variations of variable length strings.&lt;/P&gt;</description>
      <pubDate>Fri, 31 Jan 2025 03:55:27 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-can-make-JSL-read-binary-files-faster/m-p/829878#M101222</guid>
      <dc:creator>Craige_Hales</dc:creator>
      <dc:date>2025-01-31T03:55:27Z</dc:date>
    </item>
    <item>
      <title>Re: How can make JSL read binary files faster?</title>
      <link>https://community.jmp.com/t5/Discussions/How-can-make-JSL-read-binary-files-faster/m-p/829915#M101228</link>
      <description>&lt;P class=""&gt;&lt;SPAN class=""&gt;It is much faster.&lt;/SPAN&gt;&lt;/P&gt;&lt;P class=""&gt;&lt;SPAN class=""&gt;Thanks for the expert's advice.&lt;/SPAN&gt;&lt;/P&gt;&lt;P class=""&gt;&lt;SPAN class=""&gt;The original 8-byte timestamp can be converted like this.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 31 Jan 2025 08:35:37 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-can-make-JSL-read-binary-files-faster/m-p/829915#M101228</guid>
      <dc:creator>lala</dc:creator>
      <dc:date>2025-01-31T08:35:37Z</dc:date>
    </item>
  </channel>
</rss>

