1 / 16

プログラム理解における Thin slice の 統計的 調査による有用性評価

プログラム理解における Thin slice の 統計的 調査による有用性評価. 井上研究室 秦野 智臣. 背景. ソフトウェアの保守作業において,開発者はプログラム理解に多くの時間を費やしている 変数の値を調べる メソッドの呼び出し関係を調べる プログラム理解の時間を減らすための技術として,プログラムスライシングがある. プログラムスライシング. プログラム内 のある文に影響を与える可能性のあるすべての文を抽出 する技術. ソースコード 1 void main() { 2 int sum = 0; 3 int i = 1;

niel
Download Presentation

プログラム理解における Thin slice の 統計的 調査による有用性評価

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. プログラム理解におけるThinsliceの統計的調査による有用性評価プログラム理解におけるThinsliceの統計的調査による有用性評価 井上研究室 秦野 智臣

  2. 背景 • ソフトウェアの保守作業において,開発者はプログラム理解に多くの時間を費やしている • 変数の値を調べる • メソッドの呼び出し関係を調べる • プログラム理解の時間を減らすための技術として,プログラムスライシングがある

  3. プログラムスライシング • プログラム内のある文に影響を与える可能性のあるすべての文を抽出する技術 ソースコード 1 void main() { 2int sum = 0; 3 inti= 1; 4 while (i <= 10) { 5sum = sum + i; 6 i = i + 1; 7 } 8 print(i); 9} プログラムスライス 1 void main() { 3 inti= 1; 4 while (i <= 10) { 6 i = i + 1; 7 } 8 print(i); 9} スライシング • 8行目の変数iの値を知りたい場合 • に開発者の読むコードが減少 スライシング基準

  4. プログラムスライスの平均値 • プログラムスライスのサイズの平均値は,プログラム内のすべての文の約30%である[1] • 100万行のプログラムのある文について,プログラムスライシングを実行しても,平均約30万行は残る • 大規模プログラムではスライスサイズが大きくなってしまう • プログラム理解に有用であるとは言い難い [1] D. Binkley, N. Gold, and M. Harman. An empirical study of static program slice size. ACM Trans. Softw. Eng. Methodol., Vol. 16, No. 2, pp. 1-32, 2007.

  5. Thin slicing[2] • プログラム内のある文で使用しているデータについて,そのデータを生成した文のみを抽出する技術 • 変数の値を計算したり,コピーしている文 • 変数の値に着目し抽出される文を少なくする • プログラム理解に対する効果が期待できる • Thin slicingを利用して,プログラム理解の時間が大きく減少した例が22個示されている[2] [2]M. Sridharan, S. J. Fink, and R. Bodik. Thin slicing. In Proceedings of the 2007 ACM SIGPLAN Conference on PLDI, pp. 112–122., 2007.

  6. 1 package sample; 2 public class Main { 3 public static void main(String[] args) { 4 A a = new A(); 5 int id; 6 if (args.length > 0) 7 id = 1; 8 else 9 id = 0; 10 a.addData( ); 11 System.out.println(); 12 } 13 } 14 class A { 15 B b = new B(); 16 void addData(int id) { 17 b.addData( ); 18 } 19 } 20 class B { 21 int max = 4; 22 X x = new X(); 23 void addData(int id) { 24 if (id >= 0 && id <= max) 25 x.addData( ); 26 } 27 } 28 class Data { 29 int[] idList= new int[16]; 30 int count = 0; 31 void addData(int id) { 32idList[count++] = ; 33 } 34 } id id a id Thin sliceの効果が高い例 id メソッドの呼び出し関係 Main#main⇒A#addData⇒B#addData⇒Data#addData

  7. 1 package sample; 2 public class Main { 3 public static void main(String[] args) { 4 A a = new A(); 5 int id; 6 if (args.length > 0) 7 id = 1; 8 else 9 id = 0; 10 a.addData( ); 11 System.out.println(); 12 } 13 } 14 class A { 15 B b = new B(); 16 void addData(int id) { 17 b.addData( ); 18 } 19 } 20 class B { 21 int max = 4; 22 X x = new X(); 23 void addData(int id) { 24 if (id >= 0 && id <= max) 25 x.addData( ); 26 } 27 } 28 class Data { 29 int[] idList= new int[16]; 30 int count = 0; 31 void addData(int id) { 32idList[count++] = ; 33 } 34 } id id a この部分だけを見れば変数idの値が分かる id 7 id 10 17 25 32 データの生成元 9 文を頂点としたグラフで Thin sliceを計算する

  8. 1 package sample; 2 public class Main { 3 public static void main(String[] args) { 4 A a = new A(); 5 int id; 6 if (args.length > 0) 7 id = 1; 8 else 9 id = 0; 10 a.addData( ); 11 System.out.println(); 12 } 13 } 14 class A { 15 B b = new B(); 16 void addData(int id) { 17 b.addData( ); 18 } 19 } 20 class B { 21 int max = 4; 22 X x = new X(); 23 void addData(int id) { 24 if (id >= 0 && id <= max) 25 x.addData( ); 26 } 27 } 28 class Data { 29 int[] idList= new int[16]; 30 int count = 0; 31 void addData(int id) { 32idList[count++] = ; 33 } 34 } id 同じメソッド内で使用 id a id Thin sliceの効果が低い例 id メソッドの呼び出し関係 Main#main⇒A#addData⇒B#addData⇒Data#addData

  9. 研究目的と方法 • 目的 • プログラム理解におけるThin slicingの有用性を評価する • Thin sliceのサイズは平均的に十分小さくなるか • Thin sliceはプログラム理解において,どれくらい効果の高いものであるか • 方法 • Javaを対象としたThin slicingを実装し,7個のプログラムでThin sliceに関する指標を計測する

  10. 実験対象 • DaCapo benchmark • 多数のJavaプログラムが含まれている

  11. 計測する指標 • Thin sliceのサイズを計算するため • Thin sliceの頂点数 • 値が小さい⇒抽出される文が少ない • Thin sliceのプログラム理解に対する効果を調査するため • Thin sliceがまたがるメソッド数 • 値が大きい⇒データが多くのメソッドを経由する • Thin sliceのうちデータの生成元に相当する頂点数 • 値が小さい⇒データの生成元の数が少ない これらの指標を,データを使用しているすべての 頂点をスライシング基準として計測する

  12. 実験結果(1/3) • Thin sliceの頂点数の平均は,プログラム全体の約1% • 複数のメソッドにまたがるThin sliceが全スライスの約80%

  13. 実験結果(2/3) ・データの生成元の数がその最大値手前である Thinsliceが約10~20% ・残りの80%以上はデータの生成元の数が 少ない範囲に分布(この範囲内に着目) 最大値

  14. 実験結果(3/3) • 全Thin sliceの約半分について,データの生成元の数が6以下である • その約半分のThin sliceのうち,複数のメソッドにまたがるものが約60%である

  15. 考察 • Thin sliceのサイズは平均的に十分小さいと言える • 通常のスライスの平均サイズが約30%であるのに対し,Thin sliceの平均サイズは約1%である • データを使用している場所のうち約30%で,メソッド呼び出しをたどってデータの生成元を探す作業の簡略化が期待できる • 全Thin sliceの約半分でデータの生成元の数が少なく,うち約60%が複数のメソッドにまたがる

  16. まとめ • Thin sliceに関する指標を計測し,プログラム理解における有用性を評価した • Thin sliceのサイズは平均的に十分小さくなる • データの使用場所の約30%で,データの生成元をたどる作業の簡略化が期待できる • 今後の応用 • Thin sliceを利用したプログラム理解支援ツールの作成 • 実際のソフトウェア開発でThin sliceを利用する

More Related