Re: [Scilab-users] output buffer

2022-06-20 Thread Samuel Gougeon

Le 20/06/2022 à 12:04, Jean-Yves Baudais a écrit :

Hello,


Le 17/06/2022 à 23:45, Stephane Mottelet a écrit :
The buffer size is not set by Scilab and hence is always the default 
for a given platform (it can be different for macOS, Linux, Windows). 
I suppose you need to increase or decrease it for a given application?



It is just for convenience. Here a better explanation. During 
simulation, I write some variables on file (used latter for 
statistical analysis) and I use to prepare and test the 
post-processing using the partial output data. Scilab does not write 
the data one by one, but by block of size 4096. The following code 
shows this behaviour.



--> function stupidWrite(fd,n,a)
--> for i=1:n mfprintf(fd,"%d",a); end
--> endfunction
--> fd=mopen("test.am","a");
--> stupidWrite(fd,4096,1);
--> unix_g("cat test.am | wc ");
 ans  =
  "  0   0   0"
--> stupidWrite(fd,1,2);
--> unix_g("cat test.am | wc ");
 ans  =
  "  0   1    4096"
--> mclose(fd)
--> unix_g("cat test.am |wc ")
 ans  =
  "  0   1    4097"


With the C language, the size of the output buffer is managed using 
setvbuf. It seems that there is no interface for C-coded version of 
setvbuf (contrary to many input/output C function).


So my question is: "is it possible to manage the size of the output 
buffer in Scilab?"


The solution I found is to mopen and mclose the file each time I want 
to write something. Is there another solution?



To me, here the issue looks not so much about the size of the internal 
buffer, but about the inability to flush buffered data on request, 
whatever is the buffer size.
For instance, we could simply hope that, for a text file, sending an 
ascii(12) form feed alone (*) would trigger flushing the buffer, in a 
trivial, documented, and straightforward way.


By the way, the current default buffering and buffer size of mfprintf() 
would deserve being documented.


My two cents

Samuel

(*) easy to detect by the receiver: 1 byte, equal to ascii(12) => flush 
instead of writing.


___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


Re: [Scilab-users] output buffer

2022-06-20 Thread Jean-Yves Baudais

Hello,


Le 17/06/2022 à 23:45, Stephane Mottelet a écrit :
The buffer size is not set by Scilab and hence is always the default for 
a given platform (it can be different for macOS, Linux, Windows). I 
suppose you need to increase or decrease it for a given application?



It is just for convenience. Here a better explanation. During 
simulation, I write some variables on file (used latter for statistical 
analysis) and I use to prepare and test the post-processing using the 
partial output data. Scilab does not write the data one by one, but by 
block of size 4096. The following code shows this behaviour.



--> function stupidWrite(fd,n,a)
--> for i=1:n mfprintf(fd,"%d",a); end
--> endfunction
--> fd=mopen("test.am","a");
--> stupidWrite(fd,4096,1);
--> unix_g("cat test.am | wc ");
 ans  =
  "  0   0   0"
--> stupidWrite(fd,1,2);
--> unix_g("cat test.am | wc ");
 ans  =
  "  0   14096"
--> mclose(fd)
--> unix_g("cat test.am |wc ")
 ans  =
  "  0   14097"


With the C language, the size of the output buffer is managed using 
setvbuf. It seems that there is no interface for C-coded version of 
setvbuf (contrary to many input/output C function).


So my question is: "is it possible to manage the size of the output 
buffer in Scilab?"


The solution I found is to mopen and mclose the file each time I want to 
write something. Is there another solution?


Thanks,

--Jean-Yves
___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


Re: [Scilab-users] output buffer

2022-06-17 Thread antoine . elias

Hello Jean-Yves,

I tried to reproduce the problem but without success.
Could you give us an example ?

With mine, I generate a file with 8192 lines of 26624 characters.

a = "a":"z";
for i = 1:10, a = a + a;end
length(a) //26624

form = "%s\n";
for i = 1:13, form = form+form;end
length(form) /4 //8192 times "%s\n"

args = list();
args(8192) = a; //alloc list
for i = 1:8191, args(i) = a;end

fd = mopen(fullfile(TMPDIR, "mfprintf.txt"), "wt");

try
tic();
mfprintf(fd, form, args(:));
toc()
catch
end

mclose(fd);

Regards,
Antoine

Le 2022-06-17 14:41, Jean-Yves Baudais a écrit :

Hello,

In other words, how to use "setvbuf" in Scilab? Is there an equivalent
function that works with the mfprintf scilab function?

Thanks,

--Jean-Yves


Le 16/06/2022 à 10:39, Jean-Yves Baudais a écrit :

How to manage *the size*. Sorry.

Jean-Yves

Le 16/06/2022 à 10:38, Jean-Yves Baudais a écrit :

Hello,

How can we manage the output buffer when we write to a file? It seems 
that this buffer size is 4096.


Thanks,

Jean-Yves

___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users

___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users

___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


Re: [Scilab-users] output buffer

2022-06-17 Thread Stephane Mottelet

Hello,

The buffer size is not set by Scilab and hence is always the default for 
a given platform (it can be different for macOS, Linux, Windows). I 
suppose you need to increase or decrease it for a given application ?


S.

---
Stephane Mottelet

Le 2022-06-17 14:41, Jean-Yves Baudais a écrit :

Hello,

In other words, how to use "setvbuf" in Scilab? Is there an equivalent
function that works with the mfprintf scilab function?

Thanks,

--Jean-Yves


Le 16/06/2022 à 10:39, Jean-Yves Baudais a écrit :

How to manage *the size*. Sorry.

Jean-Yves

Le 16/06/2022 à 10:38, Jean-Yves Baudais a écrit :

Hello,

How can we manage the output buffer when we write to a file? It seems 
that this buffer size is 4096.


Thanks,

Jean-Yves

___
users mailing list
users@lists.scilab.org
https://antispam.utc.fr/proxy/v3?i=SXVFem5DOGVpUU1rNjdmQuxbAYzjRE578NJDXO0bRW0&r=bWt1djZ5QzcyUms5R1Nzas4Pz4hn3S9_MEd_XcyeYzHsyKCVRtQ67N89rCt3q6Xy&f=Q3ZQNmU2SnpsRFlRbUF3dm35RmWaJxuoBVu42ymMGAK3JGu3n6Y8Xa7RPvcRg_db&u=http%3A//lists.scilab.org/mailman/listinfo/users&k=syJL

___
users mailing list
users@lists.scilab.org
https://antispam.utc.fr/proxy/v3?i=SXVFem5DOGVpUU1rNjdmQuxbAYzjRE578NJDXO0bRW0&r=bWt1djZ5QzcyUms5R1Nzas4Pz4hn3S9_MEd_XcyeYzHsyKCVRtQ67N89rCt3q6Xy&f=Q3ZQNmU2SnpsRFlRbUF3dm35RmWaJxuoBVu42ymMGAK3JGu3n6Y8Xa7RPvcRg_db&u=http%3A//lists.scilab.org/mailman/listinfo/users&k=syJL

___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


Re: [Scilab-users] output buffer

2022-06-17 Thread Jean-Yves Baudais

Hello,

In other words, how to use "setvbuf" in Scilab? Is there an equivalent 
function that works with the mfprintf scilab function?


Thanks,

--Jean-Yves


Le 16/06/2022 à 10:39, Jean-Yves Baudais a écrit :

How to manage *the size*. Sorry.

Jean-Yves

Le 16/06/2022 à 10:38, Jean-Yves Baudais a écrit :

Hello,

How can we manage the output buffer when we write to a file? It seems 
that this buffer size is 4096.


Thanks,

Jean-Yves

___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users

___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


Re: [Scilab-users] output buffer

2022-06-16 Thread Jean-Yves Baudais

How to manage *the size*. Sorry.

Jean-Yves

Le 16/06/2022 à 10:38, Jean-Yves Baudais a écrit :

Hello,

How can we manage the output buffer when we write to a file? It seems 
that this buffer size is 4096.


Thanks,

Jean-Yves

___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users